Topic - F to sit
Hello, another post to help the development of my plane.
How can I make someone sit in a seat when a proximity prompt is triggered
and how can I make a GUI and control script enable for only the occupant of the seat?
Thanks,
–Luke
For proximity prompt, you’re able to teleport the player relative to the seat, and turn their walkspeed 0 for 1 second so that they spawn on top of the seat, and they are sat and can’t move. To detect WHO is sitting on the seat, there is actually a humanoid.Sit feature that you can use in your global script. You’re then able to find the player, the playerGui and enable that GUI for only the player. It can be put in a global script. I hope this helps.
humanoid.Seated:Connect(function(isSeated, seat)
print(seat) -- THIS WILL GIVE YOU THE SEAT PART. So, you can check:
if seat.Name == "Whatever" then
character.HumanoidRootPart.Position = seatBrick.Position + Vector3.new(0,1,0)
humanoid.WalkSpeed = 0
end
end)
I think you can do something like this (regualr script in the seat)
local seat = script.Parent
local prompt = seat.ProximityPrompt
local plrs = game:GetService("Players")
local GuiToClone = --Your Gui you want to display
prompt.Triggered:Connect(function(plr)
local char = plr.Character
seat:Sit(char.Humanoid)
prompt.Enabled = false
end)
local formerPlayer
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local hum = seat.Occupant
if hum then
local player = plrs:GetPlayerFromCharacter(hum.Parent)
prompt.Enabled = false
GuiToClone:Clone().Parent = player.PlayerGui
formerPlayer = player
else
formerPlayer.PlayerGui[GuiToClone.Name]:Destroy()
prompt.Enabled = true
formerPlayer = nil
end
end)
Put the ScreenGui containing everything you want to display to who is sitting where you want and change local GuiToClone = to include the location of the gui
@WarioSvug It’s okay! You can still help if you’d like! And don’t worry, maybe in the future you’ll become my level as well!
I think you could do this to also enable the controller
local seat = script.Parent
local controller = seat.ControllerScript
local prompt = seat.ProximityPrompt
local plrs = game:GetService("Players")
local GuiToClone = --Your Gui you want to display
prompt.Triggered:Connect(function(plr)
local char = plr.Character
seat:Sit(char.Humanoid)
end)
local formerPlayer
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local hum = seat.Occupant
if hum then
local player = plrs:GetPlayerFromCharacter(hum.Parent)
local plrgui = player.PlayerGui
prompt.Enabled = false
GuiToClone:Clone().Parent = plrgui
local controllerClone = controller:Clone()
controllerClone.Parent = plrgui
controllerClone.Disabled = false
formerPlayer = player
else
local plrgui = formerPlayer.PlayerGui
plrgui[GuiToClone.Name]:Destroy()
plrgui[controller.Name]:Destroy()
prompt.Enabled = true
formerPlayer = nil
end
end)
Just replace ControllerScript with the name of the controller script, make sure it’s disabled at first
local seat = script.Parent
local controller = seat.ControllerScript
local prompt = seat.ProximityPrompt
local plrs = game:GetService("Players")
local GuiToClone = script.Parent.ScreenGui
prompt.Triggered:Connect(function(plr)
local char = plr.Character
seat:Sit(char.Humanoid)
prompt.Enabled = false
controller.Disabled = false
end)
local formerPlayer
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local hum = seat.Occupant
if hum then
local player = plrs:GetPlayerFromCharacter(hum.Parent)
local plrgui = player.PlayerGui
prompt.Enabled = false
GuiToClone:Clone().Parent = plrgui
local controllerClone = controller:Clone()
controllerClone.Parent = plrgui
controllerClone.Disabled = false
formerPlayer = player
else
local plrgui = formerPlayer.PlayerGui
plrgui[GuiToClone.Name]:Destroy()
plrgui[controller.Name]:Destroy()
prompt.Enabled = true
formerPlayer = nil
end
end)
Then my controller script (local script)
local usp = game:GetService(“UserInputService”)
local enginefireupevent = script.Parent:WaitForChild(“Idle”)
usp.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType then
if input.Keycode == Enum.KeyCode.E then
enginefireupevent:FireServer()
print(“Engine Fired Up!”)
end
end
end)
then my event script:
–Events
local enginefireupevent = Instance.new(“RemoteEvent”)