I’m getting a few technical errors here (not from the compiler directly).
Character (while sitting on a chair) doesn’t return true when calling back Character:FindFirstChild("Humanoid").Sit
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:
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
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.
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
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.
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.