local run = game:GetService("RunService")
local seat = script.Parent
local weldConnection
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant then
local c0 = seat.SeatWeld.C0
local c1 = seat.SeatWeld.C1
local humanoid = seat.Occupant
local character = humanoid.Parent
local hrp = character.HumanoidRootPart
weldConnection = seat.ChildRemoved:Connect(function(child)
if child.Name == "SeatWeld" then
run.Stepped:Wait()
local weld = Instance.new("WeldConstraint")
weld.Name = "SeatWeld"
weld.Part0 = seat
weld.Part1 = hrp
weld.Parent = seat
end
end)
end
end)
this script uses weldconstraints, but it didnt work.
As I said, use WeldConstraint to weld the character and the seat when the character is seated. You can detect if the character is sitting using :GetPropertyChangedSignal("Occupant") and check if the seat.Occupant is there, which you did. The problems here are:
You are playing with Weld which is unnecessary because you will be using WeldConstraint
You are only adding the WeldConstraint if the Weld is gone, which is not the right way to do it. You have to add the WeldConstraint immediately when the character is seated.
You didnât use WeldConstraint immediately when the character is seated.
Note that you can put WeldConstraint in the seat manually and set Part0 property to the seat. Then you can just change the Part1 property to the characterâs HumanoidRootPart or torso once the character is seated.
local run = game:GetService("RunService")
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant then
local humanoid = seat.Occupant
local character = humanoid.Parent
local hrp = character.HumanoidRootPart
local seat = script.Parent
run.Stepped:Wait()
local weld = Instance.new("WeldConstraint")
weld.Name = "SeatWeld"
weld.Part0 = seat
weld.Part1 = hrp
weld.Parent = seat
end
end)
The rest of the vehicle should be anchored (including the seat), it shouldnât be welded as those welds will break when the vehicle is tweened (the script I provided is specifically for the seatâs weld between the seat and the playerâs character).
Use qPerfectionWeld for this. Thereâs an option for âNever-Break-Jointsâ, which could be beneficial to you. (You can also take apart the code and just utilize the never break joints part.)
Yep this works! I just updated the players position to be on top of the seat and anchored the humanoidrootpart. Then just unanchored it whenever the player jumps.