Having issues with using :PivotTo() to seat position. Any suggestions?

So I was using :Sit() but that doesn’t always work well. Very weird behavior. I started using :PivotTo() but this creates some strange behavior. Where the player might phase through the floor or they get stuck in a weird collision situation. Am thinking I could just slightly increase the y axis but wondering if someone has a better approach?

1 Like

What about it doesn’t work very well?

You could place the player a few studs above the seat such that they will fall into it, rather than directly pivoting to the seat position.

local seat = ...

character:PivotTo(seat.CFrame * CFrame.new(0, seat.Size / 2, 0))
2 Likes

yeah my thoughts. and it’s just awkward behavior. humanoid.Sit = flase can take time to register or doesn’t register at all so you need to have a repeat loop for that… then :Sit() can take time too so need repeat loop for that as well. just seems strange and not how it was supposed to be intended

1 Like

So I tested with adding lag and the repeat loops seem to work fine in local tests. will have to try actual place test.

1 Like

You can try to use a repeating function that stops until you sit down, using a while parameter.

Like this:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        while task.wait(0.1) do
            if character.Humanoid.Sit == false then
                character:PivotTo(seat.CFrame+CFrame.new(0,3,0))
            end
        end
    end)
end)
2 Likes

so if you’re interested i just went with this.

local isSitting = humanoid.Sit
	task.spawn(function()
		if isSitting then
			repeat
				task.wait()

				humanoid.Sit = false
			until humanoid.Sit == false
		end

		repeat
			task.wait()

			seat:Sit(humanoid)
		until humanoid.Sit == true
	end)
1 Like