This is a shop that makes your walkspeed 20 when you buy it (it is a GUI).
01 | player = script.Parent.Parent.Parent.Parent.Parent |
02 | coins = player.leaderstats.Coins |
03 | price = 50 |
04 | h = game.Workspace:FindFirstChild( "Humanoid" ) |
05 |
06 | function buy() |
07 | if coins.Value > = price then |
08 | coins.Value = coins.Value - price |
09 | h.Walkspeed = 20 |
10 | else |
11 | print 'Player has not enough money to buy!' |
12 |
13 | end |
14 | end |
15 |
16 | script.Parent.MouseButton 1 Down:connect(buy) |
01 | player = script.Parent.Parent.Parent.Parent.Parent |
02 | coins = player.leaderstats.Coins |
03 | price = 50 |
04 | h = player.Character.Humanoid -- Fixed this part for you. |
05 |
06 | function buy() |
07 | if coins.Value > = price then |
08 | coins.Value = coins.Value - price |
09 | h.WalkSpeed = 20 -- Fixed it to have a capital s! |
10 | else |
11 | print 'Player has not enough money to buy!' |
12 |
13 | end |
14 | end |
15 |
16 | script.Parent.MouseButton 1 Down:connect(buy) |
If you simply use FindFirstChild() You may end up with someone else's humanoid, though the error could be that there are no player Humanoids in the Workspace. I'm not sure if there are any other problems.