Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What should the properties of a part be when placed in a vehicle?

Asked by 5 years ago
Edited 5 years ago

When I try to change the parent of a suitcase from the player to the body of a plane, I used the script below. This will change the parent, but when I try to move the plane, it won't move with it. What should I do to fix it?

local part = script.Parent
local function OnTouched(hit)
    --if it's a suitcase, anchor it and change it's parent to the plane's body
    if hit and hit.Name == "Suitcase" then
        hit.Parent = game.Workspace.LS.Values.PlaneBody.Value
        hit.Anchored = false
    end
end

--connect events
part.Touched:connect(OnTouched)

1 answer

Log in to vote
0
Answered by 5 years ago

I have since resolved this with the use of a welding script:

while true do
    local Model = script.Parent.Parent
local Other = Model:WaitForChild("SuitcasePlacePosition")
local Main = Model:WaitForChild("Suitcase")

local Weld = Instance.new("Weld", Main)
Weld.C0 = Main.CFrame:inverse() * Other.CFrame
Weld.Part0 = Main
Weld.Part1 = Other
Weld.Name = "SuitcaseWeld"
end

Ad

Answer this question