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

Can you help me with this shop?

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

✓ Accepted answer
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.

5 comments

1

But it still doesn't work how do I find the nuyer himself?

0

You already found the buyer. I updated the script. When you write Walkspeed, the "s" needs to be capitalized.

0

Also, I'd be happy to check out your game! I'm kinda curious as to what you are making. :P

1

It's not ready but ill give you credits for helping me in the shop.

0

Ok, thanks!

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