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

I want player to lose coins when running but why dosen't it work?

I put a script in server script service and put this following:

game.Players.PlayerAdded:Connect(function(plr)
	    plr.CharacterAdded:connect(function(c)
        c:WaitForChild("Humanoid").Running:connect(function(speed)
        if speed >= 10 then
repeat 
	print("Working?")
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value -1
until
if speed < 10 then
	plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value +1
end
end
        end
end)

3 comments

0

plr.Character instead of script.Parent on line 2. You can failsafe the Character by using either a repeat wait() until line or by waiting for CharacterAdded to fire.

0

what about the humanoid.speed >= 10 then section is that gonna work? i will show you my result.

0

this is my new change but the line 9 it says Expected identifier when parsing expression,got 'if'

1 answer

Your problem is on line 2 where you said that the humanoid would be inside of Server Script service.

1 comment

0

okay but is the script working will it detect if the player is running then it will make the player lose coins?

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