Hi I am wanting to remove some of the Gui when a player sits on a seat. There are no errors with the code. The code doesn't work either. JobChange is the Gui I am wanting to disable when the player sits in seat and re enable it when they aren't sitting in seat. Script:
01 | local seat = script.Parent |
02 |
03 | local PreviousHumanoid = nil |
04 |
05 |
06 |
07 | local function Sat() |
08 |
09 | local Humanoid = seat.Occupant |
10 |
11 | if (Humanoid ~ = nil ) then |
12 |
13 |
14 |
15 | PreviousHumanoid = Humanoid |
Check if Seat.Occupant
has a value when it is changed.
01 | local seat = script.Parent |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | local previousHumanoid |
05 |
06 | seat:GetPropertyChangedSignal( "Occupant" ):Connect( function () |
07 | local newHumanoid = seat.Occupant |
08 | if (newHumanoid ~ = nil ) and (newHumanoid:IsA( "Humanoid" )) then |
09 | local player = Players:GetPlayerFromCharacter(newHumanoid.Parent) |
10 | if player ~ = nil then |
11 | player.PlayerGui.JobChange.Enabled = false |
12 | previousHumanoid = newHumanoid |
13 | end |
14 | else |
15 | if (previousHumanoid ~ = nil ) and (previousHumanoid:IsA( "Humanoid" )) then |
01 | players = game:GetService( "Players" ) |
02 | local seat = script.Parent |
03 |
04 | local PreviousHumanoid = nil |
05 |
06 |
07 |
08 | function Sat() |
09 |
10 | local Humanoid = seat.Occupant |
11 |
12 | if (Humanoid ~ = nil ) then |
13 |
14 |
15 |