Seat:Sit() not working

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
2 Likes

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.

1 Like

But that will only work for 1 seat no?

1 Like

Yes. Currently checking other codes…
Will keep you updated…

1 Like

This is working:

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.

1 Like

Thank you so much, it works now!

1 Like