Advertisement
coding_giants

CodesServer l16

Jun 19th, 2023
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.09 KB | None | 0 0
  1. local remotes = game.ReplicatedStorage.Remotes
  2. local httpService = game:GetService("HttpService")
  3. local replicatedStorage = game.ReplicatedStorage
  4. local remotes = replicatedStorage:WaitForChild("Remotes")
  5. local createTemplate = remotes:WaitForChild("CreateTemplate")
  6.  
  7.  
  8. local codes = {
  9. ["PLAY"] = {
  10. function(player)
  11. player.leaderstats.Diamonds.Value += 100000
  12. end,
  13. false,
  14. false
  15. },
  16. ["PET"] = {
  17. function(player)
  18. local petName = "18"
  19. local id = httpService:GenerateGUID()
  20. local pet = Instance.new("StringValue", player.Pets)
  21. pet.Name = petName
  22. pet.Value = id
  23. createTemplate:FireClient(player, petName, id)
  24. end,
  25. false,
  26. false
  27. },
  28. ["TURBO"] = {
  29. function(player)
  30. player.Character.Humanoid.WalkSpeed = 100
  31. end,
  32. false,
  33. true
  34. },
  35. ["BIGHEAD"] = {
  36. function(player)
  37. player.Character.Head.Size = Vector3.new(5,5,5)
  38. end,
  39. false,
  40. true
  41. },
  42. ["MINI"] = {
  43. function(player)
  44. player.Character:ScaleTo(0.5)
  45. end,
  46. false,
  47. true
  48. },
  49. ["BIG"] = {
  50. function(player)
  51. player.Character:ScaleTo(10)
  52. end,
  53. false,
  54. true
  55. },
  56. ["NIGHT"] = {
  57. function(player)
  58. game.Lighting.ClockTime = 0
  59. end,
  60. false,
  61. true
  62. },
  63. ["DAY"] = {
  64. function(player)
  65. game.Lighting.ClockTime = 11.5
  66. end,
  67. false,
  68. true
  69. },
  70. ["TACOS"] = {
  71. function(player)
  72. local sound = Instance.new("Sound")
  73. sound.SoundId = "rbxassetid://142376088"
  74. sound.Parent = player
  75. sound:Play()
  76. end,
  77. false,
  78. true
  79. }
  80. }
  81.  
  82.  
  83. remotes:WaitForChild("UseCode").OnServerInvoke = function(player,code)
  84. if codes[tostring(code)] then
  85. if player.Codes then
  86. if type(codes) == "table" then
  87. if player.Codes:FindFirstChild(tostring(code)) then
  88. return "Already"
  89. else
  90. if codes[tostring(code)][2] == true then
  91. return "Expired"
  92. else
  93. if codes[tostring(code)][3] == false then
  94. codes[tostring(code)][1](player)
  95. local usedCode = Instance.new("StringValue", player.Codes)
  96. usedCode.Name = tostring(code)
  97. return "Successfully"
  98. else
  99. codes[tostring(code)][1](player)
  100. return "Successfully"
  101. end
  102. end
  103. end
  104. else
  105. return "Unknown"
  106. end
  107. else
  108. return "Unknown"
  109. end
  110. else
  111. return "Invalid"
  112. end
  113. end
  114. Program with comments:
  115. -- Getting the Remotes object from the ReplicatedStorage
  116. local remotes = game.ReplicatedStorage.Remotes
  117.  
  118.  
  119. -- Getting the HttpService
  120. local httpService = game:GetService("HttpService")
  121.  
  122.  
  123. -- Getting the ReplicatedStorage object
  124. local replicatedStorage = game.ReplicatedStorage
  125.  
  126.  
  127. -- Getting the Remotes object from the ReplicatedStorage and waiting for it to appear
  128. local remotes = replicatedStorage:WaitForChild("Remotes")
  129.  
  130.  
  131. -- Getting the CreateTemplate object from the Remotes and waiting for it to appear
  132. local createTemplate = remotes:WaitForChild("CreateTemplate")
  133.  
  134.  
  135. -- Definition of codes and their functions
  136. local codes = {
  137. ["PLAY"] = {
  138. -- Function for the "PLAY" code - increases the player's diamond count by 100000
  139. function(player)
  140. player.leaderstats.Diamonds.Value += 100000
  141. end,
  142. -- Is the code expired? (false - it is not)
  143. false,
  144. -- Is the code reusable? (false - it is not)
  145. false
  146. },
  147. ["PET"] = {
  148. -- Function for the "PET" code - creates a new pet for the player with the name "18" and a unique ID
  149. function(player)
  150. local petName = "18"
  151. local id = httpService:GenerateGUID()
  152. local pet = Instance.new("StringValue", player.Pets)
  153. pet.Name = petName
  154. pet.Value = id
  155. createTemplate:FireClient(player, petName, id)
  156. end,
  157. false,
  158. false
  159. },
  160. ["TURBO"] = {
  161. -- Function for the "TURBO" code - increases the player's walking speed to 100
  162. function(player)
  163. player.Character.Humanoid.WalkSpeed = 100
  164. end,
  165. false,
  166. true
  167. },
  168. ["BIGHEAD"] = {
  169. -- Function for the "BIGHEAD" code - increases the size of the player's head to 5.5.5
  170. function(player)
  171. player.Character.Head.Size = Vector3.new(5,5,5)
  172. end,
  173. false,
  174. true
  175. },
  176. ["MINI"] = {
  177. -- Function for the "MINI" code - reduces the size of the player character to 50% of the original size
  178. function(player)
  179. player.Character:ScaleTo(0.5)
  180. end,
  181. false,
  182. true
  183. },
  184. ["BIG"] = {
  185. -- Function for the "BIG" code - increases the size of the player character by 10 times the original size
  186. function(player)
  187. player.Character:ScaleTo(10)
  188. end,
  189. false,
  190. true
  191. },
  192. ["NIGHT"] = {
  193. -- Function for the "NIGHT" code - changes the time in the game to 0, which represents the night
  194. function(player)
  195. game.Lighting.ClockTime = 0
  196. end,
  197. false,
  198. true
  199. },
  200. ["DAY"] = {
  201. -- Function for the "DAY" code - changes the time in the game to 11.5, which represents the day
  202. function(player)
  203. game.Lighting.ClockTime = 11.5
  204. end,
  205. false,
  206. true
  207. },
  208. ["TACOS"] = {
  209. -- Function for the "TACOS" code - plays the sound (soundID = 142376088) for the player
  210. function(player)
  211. local sound = Instance.new("Sound")
  212. sound.SoundId = "rbxassetid://142376088"
  213. sound.Parent = player
  214. sound:Play()
  215. end,
  216. false,
  217. true
  218. }
  219. }
  220.  
  221.  
  222. -- Setting the function to be called when the server receives a UseCode request from the client
  223. remotes:WaitForChild("UseCode").OnServerInvoke = function(player,code)
  224. -- Checking if the code entered exists
  225. if codes[tostring(code)] then
  226. -- Checking if the player already has any codes
  227. if player.Codes then
  228. -- Checking if the codes are a table
  229. if type(codes) == "table" then
  230. -- Checking whether the player has already used this code
  231. if player.Codes:FindFirstChild(tostring(code)) then
  232. return "Already"
  233. else
  234. -- Checking whether a code is expired
  235. if codes[tostring(code)][2] == true then
  236. return "Expired"
  237. else
  238. -- Checking whether the code is single-use
  239. if codes[tostring(code)][3] == false then
  240. -- Calling the function for the code
  241. codes[tostring(code)][1](player)
  242. -- Saving the information that a code has been used
  243. local usedCode = Instance.new("StringValue", player.Codes)
  244. usedCode.Name = tostring(code)
  245. return "Successfully"
  246. else
  247. -- Calling the function for the code
  248. codes[tostring(code)][1](player)
  249. return "Successfully"
  250. end
  251. end
  252. end
  253. else
  254. return "Unknown"
  255. end
  256. else
  257. return "Unknown"
  258. end
  259. else
  260. return "Invalid"
  261. end
  262. end
  263.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement