Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Repeat / until loop not working for detecting when a player gets off a seat?

I was wondering why this repeat loop does not work. Does the script repeat what's between repeat and until, and then move on to the rest of the script once the until statement is true?

player.Humanoid.Seated:Connect(function()
if player.Humanoid.SeatPart.Name == "GalleonSeat" then
repeat
print("Player is seated")
wait(0.1)
until player.Humanoid.Seated == false
print("Player is not sitting anymore")
	end
end)

1 answer

✓ Accepted answer

###Seated is an event of Humanoid. You're checking if an event equals true. The Seated event has two parameters, first one a boolean that is true if they're sitting, the second one is the seat they're sitting in. This can be a seat or vehicle seat.

player.Character.Humanoid.Seated:Connect(function(active, seatPart)
    if seatPart.Name == "GalleonSeat" then
        repeat
            print("Player is seated")
            wait(.1)
        until not player.Character.Humanoid.Sit -- Sit is the property you're looking for. 
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.