Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to reset leaderbored with a part?

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

game.Players.PlayerAdded:connect(function(p)
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"
	stats.Parent = p
	
	local money = Instance.new("IntValue")
	money.Name = "Coins" 
	money.Value = 50
	money.Parent = stats
end)

That's my leader bored script.

1 comment

0

Right, and where's the code that demonstrates you tried?

1 answer

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

game.Players.PlayerAdded:connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local money = Instance.new("IntValue")
	money.Name = "Coins" 
	money.Value = 50
	money.Parent = leaderstats
end)


script.Parent.Touched:Connect(function(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
	local player = game.Players:FindFirstChild(otherPart.Parent.Name)
	player.leaderstats.Coins.Value = 0 --resets points
	print(player.Name.. " reseted points to 0!") -- you can remove this
end)

Tell me when there's a problem.

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