Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how to move player name in module script table to a different module script table?

Asked by 2 years ago

I have 2 module script that i need to use for a spectate gui, 1 for alive and finished players and another one for dead players so players cant spectate players in the dead players table, but idk how to move them,

--the script

DeadPlayers = require(game.ServerStorage.DeadPlayers)
AlivePlayers = require(game.ServerStorage.FinishedAndAlivePlayers)
script.Parent.Touched:Connect(function(hit)
    for i,v in pairs(game.Players:GetPlayers()) do
        if hit:IsDescendantOf(v.Character) and not table.find(DeadPlayers,v) then
            if hit.parent.Humanoid then
                hit.Parent.Humanoid.Health = 0
                table.remove(ALivePlayers.--idkk)
                table.insert(DeadPlayers,1,v)   
            end
        end
    end
end)
0
_G greatneil80 2647 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

In line 8, you can do

table.remove(ALivePlayers,table.find(ALivePlayers,v))

table.find returns the index (number) of the found value. if table.find and can't found the value then it's nil.

Ad

Answer this question