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
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.
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.
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