I need help with my friends game we both work on it together and we are trying to make game codes like in sims where u can redeem them for stuff. i have looked on the wiki but there are no tutorials or anything for it so i thought u could help me. also which script i use local or reg
I would start by making a folder that has the tools inside then start making the gui that gives the weapon. So I would do this.
This would be the button script in your gui (specifically the submit code button)
-- Make sure its a local script lol local code = script.Parent.Parent.CodeBox local give = game.ReplicatedStorage.giveTool script.Parent.MouseButton1Click:Connect(function() if code.Text == "code" then -- if the input is code then it will fire the event give:FireServer() else print("incorrect code!") end end)
This will be the event
-- Put this in serverscriptservice local give = game.ReplicatedStorage.giveTool give.OnServerEvent:Connect(function(plr) local tool = game.Lighting.tools.Tool tool:Clone().Parent = plr.Backpack end)
This for a GUI in specific. In the gui have a textbox and a textbutton at the ready. Then just make a local script with this and put it in the gui. Then put the tool you want to give in lighting.
local tool1 = game.Lighting.Tool1 local tool2 = game.Lighting.Tool2 local button = script.Parent.TextButton local textBox = script.Parent.TextBox local player = game.Players.LocalPlayer button.MouseButton1Click:Connect (function () if textBox.Text == "Put Code You Want Here" then tool1:Clone ().Parent = player.Backpack elseif textBox.Text == "Another code here" then tool2:Clone ().Parent = player.Backpack end end)
ty Uloamis for the answer this really helps