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

My Shop don't working ?

Asked by 8 years ago

i want make a shop when you have 50$ you can add speed but it's don't work

 local player = script.Parent.Parent.Parent.Parent.Parent
 local Money = player.Stats.Points
 function buy()
 if Money.Value >= 10 then
 Money.Value = Money.Value - 10
 game.Workspace:FindFirstChild("Humanoid").WalkSpeed = 50
 end
 end
 script.Parent.MouseButton1Down:connect(buy)

0
Your grammar don't working either huh? minikitkat 687 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I assume this is a script inside a gui. If so there are a few more efficient ways you can do this. As well as a few errors you made.

local player = game.Players.LocalPlayer --Much easier way to get the player rather than a bunch of Parents
local Money = player.Stats.Points
function buy()
    if Money.Value >= 10 then
        Money.Value = Money.Value - 10
        player.Character.Humanoid.WalkSpeed = 50 --What you were trying to do was find a Humanoid specifically in the Workspace. You need to access the player's humanoid through the localPlayer.Character
    end
end
script.Parent.MouseButton1Down:connect(buy)

And make sure that the script is a LocalScript or you won't be able to access any of this. Hope this helped!

0
Thank's Pqgarvis5 0 — 8y
Ad

Answer this question