In short, I have a table that contains all players, if someone dies then they are removed. I have a life system, so if they die and they are not on 0 lives then they do not get removed.
I have a intvalue called “LivesCount” and it stores how many lives does a player have. If I put:
if Lives.Value == 0 then
-- die script
end
on a server script then that means everyone’s lives has to be 0 to make the code work, so I transferred the table to local script via remote event. It works, but the problem is that whenever I remove the player in the table with the local script, it wouldn’t be applied to the server script (I won’t be talking on why I need it on a server script now because it would be kinda long and hard to explain).
I’m a missing something here? Or is there a much simpler way to do this? Please help me with my problem and I would be forever grateful.
Here’s the code I have currently:
Server script:
for x, player in pairs (plrs) do
if player then
character = player.Character
if not character then
-- Left the game
table.remove(plrs, x)
else
if character:FindFirstChild("GameTag") then
-- They are still alive
print(player.Name.. "is still in the game!")
else
-- They are dead lol
game.ReplicatedStorage:WaitForChild("LivesButThisTimeItWillWok"):FireClient(player, plrs, x)
print(plrs)
end
end
else
table.remove(plrs, x)
player.Team = game.Teams["Not Playing"]
print(player.Name.." has been removed!")
end
Focus on the “they are dead lol” part of script
Local script:
game:GetService("ReplicatedStorage"):WaitForChild("LivesButThisTimeItWillWok").OnClientEvent:Connect(function(plrs, x)
if LivesCount.Value == 0 then
table.remove(plrs, x)
player.Team = game.Teams["Not Playing"]
print("removed?")
else
print("Life not 0")
end
end)
Thank you for reading