I'm trying to make a code that will give 50 walkspeed and 200 + life but its not work
01 | local box = script.Parent.Parent.TextBox |
02 | local plr = script.Parent.Parent.Parent.Parent |
03 | function onClick() |
04 |
05 | if box.Text = = "1337" then |
06 | box.Text = "Code Redeemed!" |
07 | wait( 2 ) |
08 | box.Text = "Special Code" |
09 | local b = game.Players.Humanoid.WalkSpeed = 50 |
10 | else |
11 | box.Text = "Wrong Code!" |
12 | wait( 2 ) |
13 | box.Text = "Special Code" |
14 |
15 |
16 | end |
17 | end |
18 | script.Parent.MouseButton 1 Click: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:
01 | local plr = game.Players.LocalPlayer |
02 | local chr = plr.Character |
03 |
04 | box = script.Parent.TEXT |
05 | code = script.Parent.CODE |
06 | function clicked() |
07 | if box.Text = = "1337" then |
08 | box.Text = "Correct!" |
09 | wait( 2 ) |
10 | box.Text = "Code" |
11 | chr.Humanoid.WalkSpeed = 50 |
12 | else |
13 | box.Text = "nope" |
14 | wait( 2 ) |
15 | box.Text = "Code" |
16 | end |
17 | end |
18 |
19 | code.MouseButton 1 Down: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.
01 | local box = script.Parent.Parent.TextBox |
02 | local plr = script.Parent.Parent.Parent.Parent |
03 | local redeemed = false |
04 |
05 | box.FocusLost:connect( function () |
06 | if box.Text = = "1337" and redeemed = = false then |
07 | redeemed = true |
08 | box.Text = "Code Accepted!" |
09 | plr.Chracter.Humanoid.WalkSpeedSpeed = 50 |
10 | wait( 1 ) |
11 | box.Text = "Redeem Code" |
12 | elseif box.Text = = "1337" and redeemed = = true then |
13 | box.Text = "Already Used!" |
14 | wait( 1 ) |
15 | box.Text = "Redeem Code" |
It is not referencing the player! Here is a fixed script.
01 | local box = script.Parent.Parent.TextBox |
02 | local player = game.Players.LocalPlayer |
03 | function onClick() |
04 |
05 | if box.Text = = "1337" then |
06 | box.Text = "Code Redeemed!" |
07 | wait( 2 ) |
08 | box.Text = "Special Code" |
09 | player.Humanoid.WalkSpeed = 50 |
10 | else |
11 | box.Text = "Wrong Code!" |
12 | wait( 2 ) |
13 | box.Text = "Special Code" |
14 |
15 |
16 | end |
17 | end |
18 | script.Parent.MouseButton 1 Click:connect(onClick) |
On line nine, you have two equal signs in different locations. Lua syntax does not permit this, remove 'local b ='.
01 | local box = script.Parent.Parent.TextBox |
02 | local plr = script.Parent.Parent.Parent.Parent |
03 | function onClick() |
04 |
05 | if box.Text = = "1337" then |
06 | box.Text = "Code Redeemed!" |
07 | wait( 2 ) |
08 | box.Text = "Special Code" |
09 | plr.Character.Humanoid.WalkSpeed = 50 |
10 | else |
11 | box.Text = "Wrong Code!" |
12 | wait( 2 ) |
13 | box.Text = "Special Code" |
14 |
15 |
16 | end |
17 | end |
18 | script.Parent.MouseButton 1 Click:connect(onClick) |