Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local remotes = game.ReplicatedStorage.Remotes
- local httpService = game:GetService("HttpService")
- local replicatedStorage = game.ReplicatedStorage
- local remotes = replicatedStorage:WaitForChild("Remotes")
- local createTemplate = remotes:WaitForChild("CreateTemplate")
- local codes = {
- ["PLAY"] = {
- function(player)
- player.leaderstats.Diamonds.Value += 100000
- end,
- false,
- false
- },
- ["PET"] = {
- function(player)
- local petName = "18"
- local id = httpService:GenerateGUID()
- local pet = Instance.new("StringValue", player.Pets)
- pet.Name = petName
- pet.Value = id
- createTemplate:FireClient(player, petName, id)
- end,
- false,
- false
- },
- ["TURBO"] = {
- function(player)
- player.Character.Humanoid.WalkSpeed = 100
- end,
- false,
- true
- },
- ["BIGHEAD"] = {
- function(player)
- player.Character.Head.Size = Vector3.new(5,5,5)
- end,
- false,
- true
- },
- ["MINI"] = {
- function(player)
- player.Character:ScaleTo(0.5)
- end,
- false,
- true
- },
- ["BIG"] = {
- function(player)
- player.Character:ScaleTo(10)
- end,
- false,
- true
- },
- ["NIGHT"] = {
- function(player)
- game.Lighting.ClockTime = 0
- end,
- false,
- true
- },
- ["DAY"] = {
- function(player)
- game.Lighting.ClockTime = 11.5
- end,
- false,
- true
- },
- ["TACOS"] = {
- function(player)
- local sound = Instance.new("Sound")
- sound.SoundId = "rbxassetid://142376088"
- sound.Parent = player
- sound:Play()
- end,
- false,
- true
- }
- }
- remotes:WaitForChild("UseCode").OnServerInvoke = function(player,code)
- if codes[tostring(code)] then
- if player.Codes then
- if type(codes) == "table" then
- if player.Codes:FindFirstChild(tostring(code)) then
- return "Already"
- else
- if codes[tostring(code)][2] == true then
- return "Expired"
- else
- if codes[tostring(code)][3] == false then
- codes[tostring(code)][1](player)
- local usedCode = Instance.new("StringValue", player.Codes)
- usedCode.Name = tostring(code)
- return "Successfully"
- else
- codes[tostring(code)][1](player)
- return "Successfully"
- end
- end
- end
- else
- return "Unknown"
- end
- else
- return "Unknown"
- end
- else
- return "Invalid"
- end
- end
- Program with comments:
- -- Getting the Remotes object from the ReplicatedStorage
- local remotes = game.ReplicatedStorage.Remotes
- -- Getting the HttpService
- local httpService = game:GetService("HttpService")
- -- Getting the ReplicatedStorage object
- local replicatedStorage = game.ReplicatedStorage
- -- Getting the Remotes object from the ReplicatedStorage and waiting for it to appear
- local remotes = replicatedStorage:WaitForChild("Remotes")
- -- Getting the CreateTemplate object from the Remotes and waiting for it to appear
- local createTemplate = remotes:WaitForChild("CreateTemplate")
- -- Definition of codes and their functions
- local codes = {
- ["PLAY"] = {
- -- Function for the "PLAY" code - increases the player's diamond count by 100000
- function(player)
- player.leaderstats.Diamonds.Value += 100000
- end,
- -- Is the code expired? (false - it is not)
- false,
- -- Is the code reusable? (false - it is not)
- false
- },
- ["PET"] = {
- -- Function for the "PET" code - creates a new pet for the player with the name "18" and a unique ID
- function(player)
- local petName = "18"
- local id = httpService:GenerateGUID()
- local pet = Instance.new("StringValue", player.Pets)
- pet.Name = petName
- pet.Value = id
- createTemplate:FireClient(player, petName, id)
- end,
- false,
- false
- },
- ["TURBO"] = {
- -- Function for the "TURBO" code - increases the player's walking speed to 100
- function(player)
- player.Character.Humanoid.WalkSpeed = 100
- end,
- false,
- true
- },
- ["BIGHEAD"] = {
- -- Function for the "BIGHEAD" code - increases the size of the player's head to 5.5.5
- function(player)
- player.Character.Head.Size = Vector3.new(5,5,5)
- end,
- false,
- true
- },
- ["MINI"] = {
- -- Function for the "MINI" code - reduces the size of the player character to 50% of the original size
- function(player)
- player.Character:ScaleTo(0.5)
- end,
- false,
- true
- },
- ["BIG"] = {
- -- Function for the "BIG" code - increases the size of the player character by 10 times the original size
- function(player)
- player.Character:ScaleTo(10)
- end,
- false,
- true
- },
- ["NIGHT"] = {
- -- Function for the "NIGHT" code - changes the time in the game to 0, which represents the night
- function(player)
- game.Lighting.ClockTime = 0
- end,
- false,
- true
- },
- ["DAY"] = {
- -- Function for the "DAY" code - changes the time in the game to 11.5, which represents the day
- function(player)
- game.Lighting.ClockTime = 11.5
- end,
- false,
- true
- },
- ["TACOS"] = {
- -- Function for the "TACOS" code - plays the sound (soundID = 142376088) for the player
- function(player)
- local sound = Instance.new("Sound")
- sound.SoundId = "rbxassetid://142376088"
- sound.Parent = player
- sound:Play()
- end,
- false,
- true
- }
- }
- -- Setting the function to be called when the server receives a UseCode request from the client
- remotes:WaitForChild("UseCode").OnServerInvoke = function(player,code)
- -- Checking if the code entered exists
- if codes[tostring(code)] then
- -- Checking if the player already has any codes
- if player.Codes then
- -- Checking if the codes are a table
- if type(codes) == "table" then
- -- Checking whether the player has already used this code
- if player.Codes:FindFirstChild(tostring(code)) then
- return "Already"
- else
- -- Checking whether a code is expired
- if codes[tostring(code)][2] == true then
- return "Expired"
- else
- -- Checking whether the code is single-use
- if codes[tostring(code)][3] == false then
- -- Calling the function for the code
- codes[tostring(code)][1](player)
- -- Saving the information that a code has been used
- local usedCode = Instance.new("StringValue", player.Codes)
- usedCode.Name = tostring(code)
- return "Successfully"
- else
- -- Calling the function for the code
- codes[tostring(code)][1](player)
- return "Successfully"
- end
- end
- end
- else
- return "Unknown"
- end
- else
- return "Unknown"
- end
- else
- return "Invalid"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement