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!
Closed as Not Constructive by RazzyPlayz, namespace25, ScuffedAI, and imKirda
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?