So I have a round based game and my problem is, I want it so that when the round ends (time runs out) it gives the players who survived points.. but how?
Server Script
game.Players.PlayerAdded:Connect(function(Player) local bool = Instance.new("BoolValue") bool.Name = "Status" bool.Value = false bool.Parent = Player Player.CharacterAdded:Connect(function(Character) local Humanoid = Character:WaitForChild("Humanoid") Humanoid.Died:Connect(function() bool.Value = false end) end) end) function Begin() for i, v in pairs(game:GetService("Players"):GetPlayers()) do v:WaitForChild("Status").Value = true end end workspace.Part1.Touched:Connect(Begin) -- Whatever event you want to check that a round is starting here function End() for i, v in pairs(game:GetService("Players"):GetPlayers()) do if v:WaitForChild("Status").Value == true then v:WaitForChild("leaderstats"):WaitForChild("Points").Value = v:WaitForChild("leaderstats"):WaitForChild("Points").Value + 25 v:WaitForChild("Status").Value = false end end end workspace.Part2.Touched:Connect(End) -- Whatever event you want to check that a round is ending here
Your code should look something like this. The Bool can go anywhere inside the player, as long as you can read it.
We can use the Player.CharacterAdded event to get the Character of the player and their corresponding humanoid.
When the humanoid dies, the bool will return to false
This example assumes you already made a leaderboard using leaderstats and Points, though the name of the folder / model depends on how you actually scripted it.