I'm trying to make a code that will give 50 walkspeed and 200 + life but its not work
local box = script.Parent.Parent.TextBox local plr = script.Parent.Parent.Parent.Parent function onClick() if box.Text == "1337" then box.Text = "Code Redeemed!" wait(2) box.Text = "Special Code" local b = game.Players.Humanoid.WalkSpeed = 50 else box.Text = "Wrong Code!" wait(2) box.Text = "Special Code" end end script.Parent.MouseButton1Click:connect(onClick)
Line 9 got an error, but i can't see it Please Help Me ASAP
Here you added the walkspeed as a Variable and you don't want to do that. I rewrote it a bit:
local plr=game.Players.LocalPlayer local chr=plr.Character box=script.Parent.TEXT code=script.Parent.CODE function clicked() if box.Text=="1337" then box.Text="Correct!" wait(2) box.Text="Code" chr.Humanoid.WalkSpeed=50 else box.Text="nope" wait(2) box.Text="Code" end end code.MouseButton1Down:connect(clicked)
You can change the name of the Variables.
You need to check if a code was entered, so you need to change your function. Also, you used "=" twice on line 9, so you need to get rid of your "local b" and change game.Players to just plr since you explained what it was. You also need to check if the code was redeemed or not already, which you would wanna set a value to check.
local box = script.Parent.Parent.TextBox local plr = script.Parent.Parent.Parent.Parent local redeemed = false box.FocusLost:connect(function() if box.Text == "1337" and redeemed == false then redeemed = true box.Text = "Code Accepted!" plr.Chracter.Humanoid.WalkSpeedSpeed = 50 wait(1) box.Text = "Redeem Code" elseif box.Text == "1337" and redeemed == true then box.Text = "Already Used!" wait(1) box.Text = "Redeem Code" else box.Text = "Code Declined!" wait(1) box.Text = "Redeem Code" end end)
It is not referencing the player! Here is a fixed script.
local box = script.Parent.Parent.TextBox local player = game.Players.LocalPlayer function onClick() if box.Text == "1337" then box.Text = "Code Redeemed!" wait(2) box.Text = "Special Code" player.Humanoid.WalkSpeed = 50 else box.Text = "Wrong Code!" wait(2) box.Text = "Special Code" end end script.Parent.MouseButton1Click:connect(onClick)
On line nine, you have two equal signs in different locations. Lua syntax does not permit this, remove 'local b ='.
local box = script.Parent.Parent.TextBox local plr = script.Parent.Parent.Parent.Parent function onClick() if box.Text == "1337" then box.Text = "Code Redeemed!" wait(2) box.Text = "Special Code" plr.Character.Humanoid.WalkSpeed = 50 else box.Text = "Wrong Code!" wait(2) box.Text = "Special Code" end end script.Parent.MouseButton1Click:connect(onClick)