Before selecting a random player, ensure that #PlayersSitting
is greater than zero.
1 Like
i tried your way and i couldnt get it eventually but i finally got it. thank u so much for ur help Will, i really appreciate it
hey man, tysm for ur help. your answer was the closest thing to the solution so i marked it.
this is what i had to do to the server script:
local remote = game.ReplicatedStorage:WaitForChild("pickupPlateEvent")
function getRandomPlr()
local plrs = game.Players:GetPlayers()
local PlayersSitting = {}
if #plrs > 1 then
for i, plr in pairs(game:GetService("Players"):GetPlayers()) do
local char = plr.Character
if char:GetAttribute("sitAttribute") == true then
table.insert(PlayersSitting, plr)
end
end
end
return PlayersSitting[math.random(1, #PlayersSitting)]
end
function Start()
wait(4)
remote:FireClient(getRandomPlr())
end
while true do
if #game.Players:GetPlayers() > 1 then
Start() -- Put this wherever you need the thing to start
break
end
wait(3)
end
1 Like
Great I could help! Good luck with your game aswell
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.