Cannot Force players into a seat

Hey, I’ve been trying to seek for what I can force the player’s character to sit in a seat, but I’m unsure if I’m doing it right, I looked at other peoples similar things to this but I cannot seem to find a way for mine to work? I’m new to forcing a player to sit but I’m pretty sure it’s not a bug it’s just my coding but I’d like to know why it won’t work, It could be the players but I tried changing and it didn’t work for me??

for i = 5, 0, -1  do
	wait(1)
	print(i)
end

for _,Players in ipairs(game.Players:GetPlayers()) do
	local chr = Players.Character
	for _,seats in pairs(workspace.Seats:GetChildren()) do
		if seats:IsA("Seat") then
			seats:Sit(chr.Humanoid)
		end
	end
end

Help would be appreciative.

You should force the player to stop being seated, you could for example force them to jump. So:

chr.Humanoid.Jump = true
seats:Sit(chr.Humanoid)

Note, I wrote this out of the top of my head, else stop them from being seated, this might work as well.

Thank you I’ll try that :] and See if this is the solution.

Else chr.Humanoid.Seated = false should probably work.

Ah rip, it’s not the solution, so It works?? But won’t jump the player nor seat them. That’s so weird.

Else you could try to wait until the player is the occupant of the seat:

repeat 
   if player.Seated and seat.Occupant ~= chr.Humanoid then 
      -- make them stop being seated in whatever way I disclosed before
   end
   wait()
   seats:Sit(chr.Humanoid)
until seats.Occupant = chr.Humanoid

Edit: Fixed the if statement, so it would not loop again possibly even though the player is not seated on the seat anymore;
Note, if another Occupant is on the seat, you should remove them from the seat.

Thank you I’ll try this one real quick!

Yeah there’s something wrong, it works for when a Player Joins but not when its doing getplayers, that is upsetting and unfortunate, I don’t know if it’s allowed to do that but that’s very unfortunate and disappointing to see.

Does the player just not sit down on any seat or only sits down on 1 seat, if you answer is any seat then else teleport the player inside the seat:

chr:SetPrimaryPartCFrame(seats.CFrame)

or

chr.PrimaryPart.CFrame = seats.CFrame

they work both the same way.

If your answer is another seat, I am quite sorry, but I have no idea how to fix this.

for i = 5, 0, -1  do
	wait(1)
	print(i)
end


for i,v in pairs(game.Players:GetChildren()) do
	local Character = v.Character
	local Humanoid = Character:WaitForChild('Humanoid')
	for a,b in pairs(workspace.Seats:GetChildren()) do
		if b:IsA("Seat") then
			if not b.Occupant and not Humanoid.Sit then -- Check if the seat isn't occupied and the player isn't already sat
				Humanoid.JumpPower = 0 -- Prevent the player from jumping
				b:Sit(Humanoid) -- Sit the player into the seat
			end
		end
	end
end
1 Like

Ah thank you, I’ve been searching for hours not seeing this response it works tsym! ")

1 Like

Thank you for helping me though too!