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 stats like coins when running?

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 :)

1 comment

0

i saw your question in my answer try now

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

2

thanks so much

1

No problem have a fantastic day

2

you too.

1

<3

1

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 '.'

1

hmm

1

paste the script again it will work

1

have a good DAY

1

reply if neeeded

1

that works but now the if speed < 8 then is not working it also says Expected identifier when parsing expression,got 'if'

1

now try

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