I need Help on a script that will reset your leaderbored stats When touching a part
01 | game.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 |
10 | end ) |
That's my leader bored script.
Add a script on the part, then put this code:
01 | game.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 |
10 | end ) |
11 |
12 |
13 | script.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 |
18 | end ) |
Tell me when there's a problem.