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

How to reset leaderbored with a part?

Asked by 4 years ago

I need Help on a script that will reset your leaderbored stats When touching a part

01game.Players.PlayerAdded:connect(function(p)
02    local stats = Instance.new("IntValue")
03    stats.Name = "leaderstats"
04    stats.Parent = p
05 
06    local money = Instance.new("IntValue")
07    money.Name = "Coins"
08    money.Value = 50
09    money.Parent = stats
10end)

That's my leader bored script.

0
Right, and where's the code that demonstrates you tried? Ziffixture 6913 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Add a script on the part, then put this code:

01game.Players.PlayerAdded:connect(function(player)
02    local leaderstats = Instance.new("Folder")
03    leaderstats.Name = "leaderstats"
04    leaderstats.Parent = player
05 
06    local money = Instance.new("IntValue")
07    money.Name = "Coins"
08    money.Value = 50
09    money.Parent = leaderstats
10end)
11 
12 
13script.Parent.Touched:Connect(function(otherPart)
14    local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
15    local player = game.Players:FindFirstChild(otherPart.Parent.Name)
16    player.leaderstats.Coins.Value = 0 --resets points
17    print(player.Name.. " reseted points to 0!") -- you can remove this
18end)

Tell me when there's a problem.

Ad

Answer this question