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

Make GUI visible when player sits on a seat?

Asked by 4 years ago

Just need to make a GUI appear when a player sits on the seat.

while true do
wait()
local player = game.Players:GetPlayerFromCharacter(script.Parent.Occupant.Parent)
    if player == game.Players.LocalPlayer.Character then
game.Players.LocalPlayer.PlayerGui.TestingGUI.TextBox.Visible = true

end

end

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

There is a humanoid event just for this called seated:

local player = game:GetService('Players').LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild('Humanoid')

humanoid.Seated:Connect(function(active)
    player.PlayerGui.TestingGUI.TextBox.Visible = active
end)

Put this in a local script in StarterGui.

You could also make this into a server script pretty easily.

More information on the seated event: https://developer.roblox.com/en-us/api-reference/event/Humanoid/Seated

Ad

Answer this question