Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant == nil then
frame.Visible = false
return
end
frame.Visible = true
end)
sorry for the title i had to get it below 100 letters
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant == nil then
frame.Visible = false
return
end
frame.Visible = true
end)
sorry for the title i had to get it below 100 letters
You should be using a RemoteEvent. For the example, it will be under ReplicatedStorage:
Server Script:
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant ~= nil then
local player = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
game.ReplicatedStorage.RemoteEvent:FireClient(player)
end
end)
Local Script (Child of StarterGUI):
game.ReplicatedStorage.OnClientEvent:Connect(function()
frame.Visible = true
end)
You do not need a RemoteEvent for this. It's an absolute waste of time. This can all be done from the client and the server doesn't have to do anything.
The property that will most certainly do you good is Humanoid.SeatPart. This will give you the part the Humanoid is sitting in, if the Humanoid's current state is Sitting and the state change was not initiated outside of a Seat.
You can call GetPropertyChangedSignal() and detect when the SeatPart is not nil:
game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
local hum = char.Humanoid
hum:GetPropertyChangedSignal("SeatPart"):Connect(function()
if hum.SeatPart then -- If SeatPart isn't nil, then move to the next line
print(hum.SeatPart.Name) -- Print the name of the SeatPart
end
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
You don't have to use a RemoteEvent.
what’s the alternative? Accessing the PlayerGUI?