Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make codes to give u weapons if u write something?

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

3 comments

0

please format your question better using the formatting tools

0

if you're writing in chat then you would be stepping in something similar to Admin Commands but if it's a text box then it's somewhat similar but not really

3 answers

✓ Accepted answer

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)

1 comment

0

uh i dont understand where am i supposed to put the tool name and if im supposed to change givetool

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)

1 comment

0

that wouldnt really work with FilteringEnabled

ty Uloamis for the answer this really helps

3 comments

0

One more thing how would u make it so that the player cant enter the same code multiple times?

0

And also how would u make the code item save if u die

0

Use leaderstats

This discussion is preserved as it was. New answers, comments, and votes are closed.