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

I want player to lose stats like coins when running? [closed]

Asked by 4 years ago

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

0
i saw your question in my answer try now raid6n 2196 — 4y

Closed as Not Constructive by hiimgoodpack and Torren_Mr

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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

2
thanks so much mastercheeseit 77 — 4y
1
No problem have a fantastic day raid6n 2196 — 4y
2
you too. mastercheeseit 77 — 4y
1
<3 raid6n 2196 — 4y
View all comments (7 more)
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 '.' mastercheeseit 77 — 4y
1
hmm raid6n 2196 — 4y
1
paste the script again it will work raid6n 2196 — 4y
1
have a good DAY raid6n 2196 — 4y
1
reply if neeeded raid6n 2196 — 4y
1
that works but now the if speed < 8 then is not working it also says Expected identifier when parsing expression,got 'if' mastercheeseit 77 — 4y
1
now try raid6n 2196 — 4y
Ad