In my Game, I’m trying to give 10 points, and 1 “Survival” stat to each player who survives the round.
Currently, it will only give the surviving players the points as intended, however, if a player dies and then wins the next round, they get double points and double Survivals. Basically, they win the points they didn’t get from the round they died during, as well as the points they earned for the second round.
I tried fixing it but I have no idea why the script is doing this. I suspect it’s storing the points that each player who died didn’t earn, and then dispensing them all at once as soon as the player wins a round.
In my script down below, InRound basically means if the round is still ongoing or not, and DeadCheck is just checking to see whether the player died during the round or not.
Here’s the script
local DeadCheck = Instance.new("BoolValue")
DeadCheck.Name = "DeadCheck"
DeadCheck.Parent = Player
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
DeadCheck.Value = true
Humanoid.Died:Connect(function()
DeadCheck.Value = true
end)
InRound.Changed:Connect(function()
for i,player in pairs(game.Players:GetChildren()) do
if InRound.Value == true then
DeadCheck.Value = false
print(player.DeadCheck.Value)
end
if DeadCheck.value == false and InRound.Value == false then
for _,plr in pairs(game.Players:GetChildren()) do
game.ReplicatedStorage.Survivors.Value = plr.Name
if player.DeadCheck.Value == false then
local stats = plr:FindFirstChild("leaderstats")
if stats then
stats.Points.Value = stats.Points.Value +10
stats.Survivals.Value = stats.Survivals.Value + 1
end
end
end
end
end
end)
end)
end)