Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
2
Answered by 5 years ago

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)
Ad

Answer this question