-
I am trying to make ProximityPrompt work with vehicle seat called DriveSeat.
-
The issue is that the ProximityPrompt on DriveSeat shows up even if I am sat on passenger seat, which shouldn’t happen.
-
I’ve tried looking at DevForum and still couldn’t find a solution.
So this is a ServerScript that is included in the ProximityPrompt:
local ProximityPromt = script.Parent
local seat = ProximityPromt.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant then
ProximityPromt.Enabled = false
else
ProximityPromt.Enabled = true
end
end)
ProximityPromt.Triggered:Connect(function(player)
seat:Sit(player.Character.Humanoid)
end)
And this is the LocalScript included in StarterCharacterScripts to hide the proximity prompts once sat.
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local formersit
hum.Seated:Connect(function(seated, seatpart)
if seated then
local model = seatpart:FindFirstAncestorOfClass("Model")
for _,v in pairs(model:GetDescendants()) do
if v.ClassName ~= "ProximityPrompt" then continue end
v.Enabled = false
end
formersit = model
else
for _,v in pairs(formersit:GetDescendants()) do
if v.ClassName ~= "ProximityPrompt" then continue end
v.Enabled = true
end
formersit = nil
end
end)
Here’s a gif of my problem.
https://i.imgur.com/cOrUms6.mp4
Here’s the passenger seat.
Here’s the driver seat.