Character Seating Errors

I’m getting a few technical errors here (not from the compiler directly).

  1. Character (while sitting on a chair) doesn’t return true when calling back Character:FindFirstChild("Humanoid").Sit

  2. Character (while sitting down on a chair – Seat, should I say) will teleport WITH the chair.

I tried doing the whole Humanoid.Sit = false before teleporting trick. However, I’m still getting the same results with the Seat being teleported with the character.

Here’s my code if anyone wants to look at it:

  1. This is supposed to tell me if the character is sitting or not
for i, v in ipairs(game.Players:GetChildren()) do
	--local occupiedSeat = game.Players:FindFirstChild(v).Character:FindFirstChild("Humanoid").SeatPart;
	--print (occupiedSeat);
		
	if v.Character:FindFirstChild("Humanoid").Sit == true then
		print("I AM SITTING!");
	else
		print("I AM NOT SITTING");
	end	
end
  1. And this is supposed to teleport the character from his seat (while sitting) to the destination
if game.Players:FindFirstChild(v).Character and game.Players:FindFirstChild(v).Character:FindFirstChild("HumanoidRootPart") then -- Make sure the player's character and HumanoidRootParts exist
    				
	-- ** ERROR HERE ** FIND OUT WHY SEAT IS GETTING TELEPORTED WITH PLAYER
					
	playerHumanoid = game.Players:FindFirstChild(v).Character:FindFirstChild("Humanoid");
	playerHumanoid.Sit = false;
	game.Players:FindFirstChild(v).Character.HumanoidRootPart.CFrame = teleportationTarget + Vector3.new(0, 5, 0);
	setTeamFired(game.Players:FindFirstChild(v), "Spectators");
end

Could it also be because I teleported the characters into their seats instead of them walking to the seats themselves? In the game, I basically teleport them right next to the Seat to get them to sit. I’m clueless at this point.

Delete the seat weld when you are teleporting so the seat doesn’t go with it.

Gotcha. The weld is made after a player sits on it, correct? Or should I just create a SeatWeld myself?

Also, I’m using this code as well to check all the seats to see if they are being sat on or not. It’s not working for me for some reason:

for i, v in pairs(game.Workspace.Objects.Chairs:GetChildren()) do -- Iterate through all the chair objects
	if v.Seat.Occupant ~= nil then
		print (v);
	end
end

The SeatWeld is created with the HumanoidRootPart and the seat when the players sits.

The reason I assume your code isn’t working is because your specifying Seat inside of a Seat class.

Change v.Seat.Occupant to v.Occupant like this…

for i, v in pairs(game.Workspace.Objects.Chairs:GetChildren()) do -- Iterate through all the chair objects
	if v.Occupant ~= nil then
		print (v);
	end
end
1 Like

Question. So, for my game.Workspace.Objects.Chairs:GetChildren() part. I have chair objects that I made on Blender and put a Seat inside of them.

I’m getting this error when I change v.Seat.Occupant to v.Occupant :

Occpuant is not a valid member of Model “Workspace.Objects.Chairs.Nano_Chair_01”

Where exactly is the seat located?

Untitled

Ok, so change it to v.Seat.Occupant. It should be working, is there any errors when you have this?

You should use Humanoid:GetState() == Enum.HumanoidStateType.Sitting (or Sit, can’t remember) to check if the humanoid is sitting instead. You also can’t force the character from sitting on the client if I recall correctly, but I think the server can.

Ok I have found out the reason it teleports the seat with it. You have to wait until the SeatWeld is removed before teleporting otherwise when you disable sit on the humanoid and teleport really fast it will still be welded for that short period of time.

https://gyazo.com/53765d242cef097fc2fda3f32c28e1b3

No errors here unfortunately. I can’t figure out what is happening. I think it worked the first time I tried doing it this way, but after I implemented some more things (A LOT of things), it just stopped working.

Idk if you spelled it wrong but its Occupant not Occpuant.

Here is some code I used to teleport from a seat without it teleporting the seat a long with it. You could hopefully learn from this.

workspace.ScriptingVoid.Humanoid.Sit = false 
repeat wait() until not workspace.Seat:FindFirstChild("SeatWeld") 
workspace.ScriptingVoid.HumanoidRootPart.CFrame = CFrame.new(6.434, 3, -20.599)
1 Like

Sorry. I typed that error message haha. I’m using two different computers and didn’t know how to copy and paste it from one to the other. :smiley: