Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you help me with this shop?

Asked by 9 years ago

This is a shop that makes your walkspeed 20 when you buy it (it is a GUI).

player = script.Parent.Parent.Parent.Parent.Parent
coins = player.leaderstats.Coins
price = 50
h = game.Workspace:FindFirstChild("Humanoid")

function buy()
if coins.Value >= price then
coins.Value = coins.Value - price
h.Walkspeed = 20
else
print 'Player has not enough money to buy!'

end 
end

script.Parent.MouseButton1Down:connect(buy)

1 answer

Log in to vote
1
Answered by
Nifer2 174
9 years ago
player = script.Parent.Parent.Parent.Parent.Parent
coins = player.leaderstats.Coins
price = 50
h = player.Character.Humanoid -- Fixed this part for you.

function buy()
if coins.Value >= price then
coins.Value = coins.Value - price
h.WalkSpeed = 20 -- Fixed it to have a capital s!
else
print 'Player has not enough money to buy!'

end 
end

script.Parent.MouseButton1Down: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.

1
But it still doesn't work how do I find the nuyer himself? chill22518 145 — 9y
0
You already found the buyer. I updated the script. When you write Walkspeed, the "s" needs to be capitalized. Nifer2 174 — 9y
0
Also, I'd be happy to check out your game! I'm kinda curious as to what you are making. :P Nifer2 174 — 9y
1
It's not ready but ill give you credits for helping me in the shop. chill22518 145 — 9y
0
Ok, thanks! Nifer2 174 — 9y
Ad

Answer this question