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 5 years ago

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

1while true do
2wait()
3local player = game.Players:GetPlayerFromCharacter(script.Parent.Occupant.Parent)
4    if player == game.Players.LocalPlayer.Character then
5game.Players.LocalPlayer.PlayerGui.TestingGUI.TextBox.Visible = true
6 
7end
8 
9end

1 answer

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

There is a humanoid event just for this called seated:

1local player = game:GetService('Players').LocalPlayer
2local character = player.Character or player.CharacterAdded:Wait()
3local humanoid = character:WaitForChild('Humanoid')
4 
5humanoid.Seated:Connect(function(active)
6    player.PlayerGui.TestingGUI.TextBox.Visible = active
7end)

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