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?
I need to make a way so at the end of my round based game the winner gets points...?
1 answer
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.
3 comments
So I take it Begin() is when the round starts? And what is Part1 and Part2?
Part1 and Part2 are arbitrary to show you an event connection. It doesn't have to be touchbased and yes, begin is when the round starts
Thank you so much your script works practicaly flawlessly as far as I can tell. I sent you a friend request so you can see the script in full action(You don't have to and if you do you can unfriend me whenever) it took me a while to realize what to do but then I just threw in the Begin() and End() in my map picking loop and it worked out! Thanks
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
You will need a bool, that will turn true when the player begins a round and false when they die. Then check at the end of the round if the bool is still true then edit their points, the points are a leaderstat for you right?
@SerpentineKing Where would I put the bool?