Here is a weld 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
It works, but when I destroy the weld and do it again in the same game it will not work as it has already been through the script. When I start with while true do, however, it simply crashes studio when I try to weld it at the start. How do I fix it?
While true do loops require a wait(), I usually place the wait() after everything, basically before the end.
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" wait() --See? end
You can change the wait to any number you want, but the number in the brackets is how long it will wait until looping again.