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

I got a script for codes to give players items, need help adding more to it help please?

This is the script I have, it works fine, I need help to find out how to able the player to be able to enter two or maybe more different codes, if someone could help it would be much appreciated! Find my current script below.

local gear = game.ReplicatedStorage:WaitForChild('AssaultRifle')
script.Parent.MouseButton1Click:connect(function()
    if script.Parent.Parent.Input.Text == 'Gun!' then
 gear:Clone().Parent = game.Players.LocalPlayer.Backpack
 gear:Clone().Parent = game.Players.LocalPlayer.StarterGear
 script.Parent.Parent.Input.Text = ''
 script.Parent.Parent.Text = 'Success!'
 wait(1)
 script.Parent.Text = 'Submit'
 else
script.Parent.Parent.Input.Text = ''
script.Parent.Text = 'Invalid Code'
wait(1)
script.Parent.Text = 'Submit'
end
end)

As I said this script works for the current code, but I want players to be able to enter 2 codes, (once someone helps me I'm sure I could add more on my own) I've tried to have another script with the same script but I need 2 submit buttons! Help please! :)

2 comments

0

Please format your code by pressing the Lua button and placing your code in between the generated lines.

0

Oh thanks, done it now :)

1 answer

✓ Accepted answer
local gear = game.ReplicatedStorage:WaitForChild('AssaultRifle') 
local gear1= game.ReplicatedStorage:WaitForChild(' ')
script.Parent.MouseButton1Click:connect(function()
 if script.Parent.Parent.Input.Text == 'Gun!' then 
gear:Clone().Parent = game.Players.LocalPlayer.Backpack 
gear:Clone().Parent = game.Players.LocalPlayer.StarterGear 
script.Parent.Parent.Input.Text = '' 
script.Parent.Parent.Text = 'Success!'
wait(1) 
script.Parent.Text = 'Submit' else 
script.Parent.Parent.Input.Text = '' 
script.Parent.Text = 'Invalid Code' 
wait(1) 
script.Parent.Text = 'Submit'

if script.Parent.Parent.Input.Text == 'gear1' then 
gear1:Clone().Parent = game.Players.LocalPlayer.Backpack 
gear1:Clone().Parent = game.Players.LocalPlayer.StarterGear 
script.Parent.Parent.Input.Text = '' 
script.Parent.Parent.Text = 'Success!'
wait(1) 
script.Parent.Text = 'Submit' else 
script.Parent.Parent.Input.Text = '' 
script.Parent.Text = 'Invalid Code' 
wait(1) 
script.Parent.Text = 'Submit'

end
end 

2 comments

0

This doesn't seem to work, for some reason when I add this not even the first item doesn't work now. Anything else i could try?

0

make sure lines 1 (and other gear names) are matched where you have them like "gafhasfkh" would have to be "gafhasfkh" excatly

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