I have a vehicle chassis that can be entered by sitting manually and by calling :Sit(). Whenever I try to do this though, it teleports the vehicle to the player, not the other way around, causing constraints to break.
A recommended fix in here is to set RootPriority above the character’s RootPriority, but that does nothing to fix the issue.
The code below is what I currently have for handling entering the car. Is there any suggestions on what I can do to fix the teleporting?
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant ~= nil then
Prompt.Enabled = false
local Humanoid = Seat.Occupant
local Player = Players:GetPlayerFromCharacter(Humanoid.Parent)
ChassisPart:SetNetworkOwner(Player)
else
Prompt.Enabled = true
ChassisPart:SetNetworkOwnershipAuto()
end
end)
Prompt.Triggered:Connect(function(Player)
if Seat.Occupant then
return
end
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
if not Humanoid then
return
end
Seat:Sit(Humanoid)
end)
I was setting this up to duplicate your issue and had to set the Seat to massless to make that happen. That would also be your fix however you wanted to do that. Mass or an Anchor on the Seat, either one could also be used at the moment and set back.
I would just let the Seat have mass.
Testing Script
--serverScript
task.wait(6)
local Players=game:GetService("Players")
local Seat= workspace:FindFirstChild("Seat")
local Prompt=Seat:WaitForChild("ProximityPrompt")
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant then Prompt.Enabled = false
local Humanoid = Seat.Occupant
local Player = Players:GetPlayerFromCharacter(Humanoid.Parent)
Seat:SetNetworkOwner(Player)
else
Prompt.Enabled = true
Seat:SetNetworkOwner()
end
end)
Prompt.Triggered:Connect(function(Player)
if Seat.Occupant then
return
end
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
if not Humanoid then
return
end
Seat:Sit(Humanoid)
end)