Why will my script not work? It does not print out anything from what I put.
local Players = {}
game.ReplicatedStorage.HostStuff.AddPlayer.OnServerEvent:Connect(function(plr)
if plr:GetRankInGroup(6559630) >= 20 then
if not table.find(Players, plr.Name) then
print("Player is not in host system but now is.")
table.insert(Players, plr.Name)
else
print("Player is already in the host system")
end
end
end)
Is the :GetRankInGroup() part working fine? If it is then try this:
local Players = {}
game.ReplicatedStorage.HostStuff.AddPlayer.OnServerEvent:Connect(function(plr)
if plr:GetRankInGroup(6559630) >= 20 then
if not Players[plr] then
print("Player is not in host system but now is.")
Players[plr] = true
else
print("Player is already in the host system")
end
end
end)
That fixes it, now I am trying to do this but have an error:
local Players = {}
game.ReplicatedStorage.HostStuff.HostAddPlayer.OnServerEvent:Connect(function(plr)
if plr:GetRankInGroup(6559630) >= 20 then
if not Players[plr] then
print("Player is not in host system but now is.")
for i, v in pairs(game.Players:GetChildren()) do
local clone = game.ServerStorage.Name:Clone()
clone.Parent = v.PlayerGui.SurfaceGui.ListDown
clone.Text = plr.Name
end
Players[plr] = true
else
print("Player is already in the host system")
end
end
end)
You’re saving an instance inside of a table, so it would be:
game.ReplicatedStorage.HostStuff.HostAddPlayer.OnServerEvent:Connect(function(plr)
if plr:GetRankInGroup(6559630) >= 20 then
if not Players[plr.Name] then
print("Player is not in host system but now is.")
for i, v in pairs(game.Players:GetPlayers()) do
local clone = game.ServerStorage.Name:Clone()
clone.Parent = v.PlayerGui.SurfaceGui.ListDown
clone.Text = plr.Name
end
Players[plr.Name] = true
else
print("Player is already in the host system")
end
end
end)
I recommend using :WaitForChild() or :FindFirstChild(), so do this: v:FindFirstChild("PlayerGui"):FindFirstChild("SurfaceGui"):WaitForChild("ListDown")