Telporting player into a seat!

How would I teleport a player into a seat I saw something like seat:Sit() but idk how to use that. Cause I’m trying to go through all the players and make the ones who are not sitting in a seat, they need to get teleporten into an empty one.

local debounce = false

game:WaitForChild("ReplicatedStorage").Values.StoryValues.TeleportPlayersOnBus:GetPropertyChangedSignal("Value"):Connect(function()
	for i, player in pairs(game.Players:GetPlayers()) do
		if player.Character then
			local character = player.Character
			if character.Humanoid.Sit.Value == false then
				for i,v in pairs(game.Workspace.HouseMap.SchoolBus.Seats:GetChildren()) do
					if debounce == false then
						debounce = true
						
					end
				end
			end
		end
	end
end)

According to the documentation of the SeatPart:Sit(humanoid) method, you must pass a Humanoid instance onto the method.

A way to check if a player is currently sitting in a SeatPart is to check the ``SeatPart` property of the Humanoid. A SeatPart will exist in the property should the Humanoid is sitting on a SeatPart.

1 Like

:spoon:

local replicatedstorage = game:GetService("ReplicatedStorage")
    local values = replicatedstorage:WaitForChild("Values")
        local storyValues = values:WaitForChild("StoryValues")
            local value = storyValues:WaitForChild("TeleportPlayersOnBus");

value:GetPropertyChangedSignal("Value"):Connect(function()
	for i, player in pairs(game.Players:GetPlayers()) do
		if player.Character then
			local character = player.Character
			if character.Humanoid.Sit.Value == false then
				for i,seat in pairs(game.Workspace.HouseMap.SchoolBus.Seats:GetChildren()) do
					if not seat.Occupant then
						seat:Sit(character.Humanoid)
					end
				end
			end
		end
	end
end)

You have to check first if the seat is occupied or not.

game:WaitForChild("ReplicatedStorage").Values.StoryValues.TeleportPlayersOnBus:GetPropertyChangedSignal("Value"):Connect(function()
	for i, player in pairs(game.Players:GetPlayers()) do
		if player.Character then
			local character = player.Character
			if character.Humanoid.Sit.Value == false then
				for i,v in pairs(game.Workspace.HouseMap.SchoolBus.Seats:GetChildren()) do
					if not v.Occupant then
						v:Sit(character.Humanoid)
					end
				end
			end
		end
	end
end)

Wrong, youre checking if occupant is NOT nil.

1 Like

for some reason nothing happends the player doesnt teleport into the seat