I’m trying to get people to sit down around a table, and so I have a model with all the seats, and I’m looping through the players and the model to get them inside a seat.
Any ideas why this isn’t working?? All the prints come out as they should.
for i,v in pairs(Seats:GetChildren()) do
print("Yes")
for i,players in pairs(game:GetService("Players"):GetChildren()) do
print("Ok..")
local char = players.Character
if not v.SeatTaken.Value == true then
print("Success!")
v:Sit(char:FindFirstChild("Humanoid"))
print(char:FindFirstChild("Humanoid"))
print(v)
print(players)
end
end
end
Seems to be an Issue with :GetChildren. With this code it is working on studio:
wait(5)
local seats = script.Parent.Seats
for i , player in pairs(game:GetService("Players"):GetChildren()) do
--for i, v in pairs(seats:GetChildren()) do
local v = seats.Seat
local char = game.Workspace:FindFirstChild(player.Name)
v:Sit(char:FindFirstChildOfClass("Humanoid"))
print(char:FindFirstChildOfClass("Humanoid"))
print(player.Name)
--end
end
Will keep you updated when I find something better.
wait(5)
local seats = script.Parent.Seats
for i , player in pairs(game:GetService("Players"):GetChildren()) do
for i, v in pairs(seats:GetChildren()) do
local char = game.Workspace:FindFirstChild(player.Name)
if not char:FindFirstChildOfClass("Humanoid").Sit == true then
if not v.SeatTaken.Value == true then
v:Sit(char:FindFirstChildOfClass("Humanoid"))
print(char:FindFirstChildOfClass("Humanoid"))
print(player.Name)
end
end
end
end
This is because the player already sat and then calling again the Sit function cause an error.