Hi there. I need to make a leaderboard which goes up by 1 points, say, every5 seconds the player doesn't die. I also need the learderboard to reset when the player dies. Thanks you!
(Also, the leaderboard is called "Points")
Hi there. I need to make a leaderboard which goes up by 1 points, say, every5 seconds the player doesn't die. I also need the learderboard to reset when the player dies. Thanks you!
(Also, the leaderboard is called "Points")
Hello.
Before this question gets answered, please note that ScriptingHelpers is NOT a request site! ScriptingHelpers is only here for answering questions or issues you have with your code.
If you do request in ScriptingHelpers, your post will most likely be taken down. Furthermore, I suggest you giving the system a try as well, it gives you practice!
Anyway, with that out of the way, you can simply add a while loop to the leaderstats code, that updates the Points value by 1 every 5 seconds. This will keep updating the Points every time with addition.
You can then use the Humanoid.Died function to determine when the Player dies, and we can then reset the points to 0.
Here's an example:
local Players = game:GetService("Players")
local UpdatePoints = false
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
UpdatePoints = true
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = Player
local Points = Instance.new("IntValue")
Points.Name = "Points"
Points.Parent = Leaderstats
Player.leaderstats.Points.Value = 0
local Humanoid = Character.Humanoid
Humanoid.Died:Connect(function()
UpdatePoints = false
Player.leaderstats.Points.Value = 0
end)
while (UpdatePoints) do
wait(5)
Player.leaderstats.Points.Value += 1
if not (UpdatePoints) then
break
end
end
end)
end)
Hope this helps!
I like how you say that this isn't a request site yet you still fullfil his request.
Yep, I always like to help out, though, it's always good to let people know the rules as well.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
This is not a request!