✓ Accepted answer
A better way to do this is to listen for the "Occupant" property of the seat being changed. Here's how it should look:
local seat = workspace.Seat
function SeatChanged(propertyChanged)
if propertyChanged == "Occupant" then
if seat.Occupant then
game.Players.LocalPlayer.PlayerGui.seatgui.Frame.Visible = true
else
game.Players.LocalPlayer.PlayerGui.seatgui.Frame.Visible = false
end
end
end
seat.Changed:connect(SeatChanged)
What this code does is connect the SeatChanged function with any property of the seat being changed. From there, it checks if the property that was changed was "Occupant", which is the player when the seat is occupied. Then, it simply checks if the player exists in that property; If not, it closes the GUI, if so, it opens it.
If I've helped you, be sure to mark my answer correct :)
1 comment
Thank you for the help, I greatly appreciate it!