Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.