i don't have any code because i don't know what to put in it and please include where i put the script in it Thanks :)
I want player to lose stats like coins when running?
1 answer
First, we need to detect if the player is running or not.
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
c:WaitForChild("Humanoid").Running:connect(function(speed)
if speed > 8 then
print(speed)
end)
end)
end)
That script should detect how fast the player is going, usually when over 8 they are running, so you can raise it if needed
Now the removing coins.
local leaderstats = p:WaitForChild("leaderstats").Coins
leaderstats.Value = leaderstats.Value - 1
To put them together do:
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
c:WaitForChild("Humanoid").Running:connect(function(speed)
if speed > 8 then
repeat
print(speed)
local leaderstats = p:WaitForChild("leaderstats").Coins
leaderstats.Value = leaderstats.Value - 1
until speed < 8 then
wait()
end
end)
end)
end)
make sure the last script is in server script storage
11 comments
thanks so much
No problem have a fantastic day
you too.
<3
the part where you put local leaderstats.Value = leaderstats.Value - 1 the part leaderstats.Value the full stop punctuation is not working it says Expected identifier when parsing expression,got '.'
hmm
paste the script again it will work
have a good DAY
reply if neeeded
that works but now the if speed < 8 then is not working it also says Expected identifier when parsing expression,got 'if'
now try
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
i saw your question in my answer try now