Last time I asked this a bunch of devs started arguing. All I wan’t to know is how can I create a local script that will enable a gui ONLY for the person in the seat. When sitting it shows. As soon as I jump out it disables, jump back in it shows.
You can use the touch event, and touchended event. hope this helps.
Nope. I don’t want the GUI to show when I touch a part, only when I sit in a seat. Humanoid.sitting I think.
yeah, you can put the touch event inside the seat like: script.Parent.Touched:Connect(function(hit)
If you want to detect if the humanoid is sitting then just use:
local hum = game.Players.LocalPlayer.Character.Humanoid
hum:GetPropertyChangedSignal("Sit"):Connect(function()
if hum.Sit == true then
-- open GUI
end
end)
But, if you want it for 1 seat only then you can use:
local Seat = -- Path to seat
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant.Parent == game.Players.LocalPlayer.Character then
-- open gui
end
end)
local Player = game.Players.LocalPlayer -- Get Player
local Character = Player.Character -- Get Character
local Humanoid = Character:WaitForChild("Humanoid") -- Get Humanoid
local PlayerGUI = Player:WaitForChild("PlayerGui") -- Get PlayerGui
local NeededGUI = PlayerGUI:WaitForChild("YourGUIName") -- Change YourGUIName
Humanoid:GetPropertyChangedSignal("Sit"):Connect(function() -- When Player Sits or Gets Up We Detect a Signal
if Humanoid.Sit == true then -- Is Sitting
NeededGUI.Enabled = true -- Enables GUI
else -- Not Sitting
NeededGUI.Enabled = false -- Disables GUI
end
end)
This should be A LocalScript.
This would work, except I need it to constantly check if a plaer is in the seat or not. Not just once, so If a player jumps out or dies it will disable.
It should work with that Aswell,
Whenever the Player jumps Out or Sits in, it Detects and Updates Accordingly.
Even if the Player Dies, it will Check and Make the GUI Enabled and Disabled accordingly.
game.Players.LocalPlayer.CharacterAdded:Connect(function()
-- put the code you want inside this in a local script
end)
Okay, just added it to a local script inside my seat and It didn’t work. Do I neeed to change this to only work with one seat?
That local Script should be
In StarterGUI.
LocalScripts dont work if they Are Parented to An Instance which is Indirectly
Parented to Workspace.
That won’t work. I will have multiple rockets so I require it to refer to my seat as some sort of script.parent. Can’t do this as a workspace.rocket.seat
I Assume Your Making A StoryGame?
Anyways,
You can Use a Table to Check what Players are Sitting in the Rocket.
Can You show the Script which Teleports the Player to A Seat If you have A Script for it?
Not a story game. Rocket spawns and there will be a pilot seat. This player gets the guis that decide wether to go to moon, iss etc. Passenger can’t do any of this. You walk into the seat and can jump out at any time.
You can Insert A Script in Each Seat.
This is what the Script should Contain.
local Seat = script.Parent -- Seat
local PlayerSitting -- Blank Variable
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant == nil then -- Player Jumped Out
if PlayerSitting ~= nil then -- Player Is In Game (Did not Leave Game)
local PlayerUI = PlayerSitting:WaitForChild("PlayerGui")
local NeededUI = PlayerUI:FindFirstChild("GUIName") -- Change this To Your GUI Name
NeededUI.Enabled = false
PlayerSitting = nil -- Set The Var to nil
end
else -- Someone Sat Down
PlayerSitting = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
local PlayerUI = PlayerSitting:WaitForChild("PlayerGui")
local NeededUI = PlayerUI:FindFirstChild("GUIName") -- Change this To Your GUI Name
NeededUI.Enabled = true
end
end)
This Should be a Script and Not A LocalScript
Thankyou so much, been trying to do this for ages.
Any chance I can re-disable this if an bindable event is fired? Any way I can also enable it if an event is fired. For example, the gui doesn’t show until an event is fired.
Where do you put the Gui? Probably a dumb question, but I am clueless.
Inside of the seat.
characterlimit go brrrr