Hello! I am having trouble with my custom admin commands. I am trying to loop through all of the players and respawn them, but it only respawns me.
Even when I print the names, it still doesn’t respawn “KLB_Tester.”
My Code:
if char2 == "all" then
for i,v in pairs(game.Players:GetPlayers()) do
local Character = v.Character
local Humanoid = Character.Humanoid
plr:LoadCharacter()
print(v.Name)
end
print("DONE")
return
end
The full code:
_G.Respawn = function(char2, plr)
if plr == nil then
if game.Players:FindFirstChild(char2.Name) then
local Character = char2.Character
local Humanoid = Character.Humanoid
char2:LoadCharacter()
end
return
end
if char2 == "all" then
for i,v in pairs(game.Players:GetPlayers()) do
local Character = v.Character
local Humanoid = Character.Humanoid
plr:LoadCharacter()
print(v.Name)
end
print("DONE")
return
end
if char2 == "others" then
for i,v in pairs(game.Players:GetChildren()) do
if v.Name ~= plr.Name then
local Character = v.Character
local Humanoid = Character.Humanoid
plr:LoadCharacter()
end
end
return
end
if char2 == "me" then
if game.Players:FindFirstChild(plr.Name) then
local Character = plr.Character
local Humanoid = Character.Humanoid
plr:LoadCharacter()
end
return
end
for i,v in pairs(game.Players:GetChildren()) do
local vName = string.lower(v.Name)
if vName:sub(1, #char2) == char2 then -- 1 is where is starts, #char2 is how far to serch.
local Name = v.Name
local Character = v.Character
local Humanoid = Character.Humanoid
plr:LoadCharacter()
return
end
end
end
I am really stuck on this. Please help!