Hello,
I am new to scripting and messing around with CFraming. I have a model I am CFraming based off its primary part, but one of the parts just won't weld with my weld script. This is a problem, because it is being used as the position to look at for another part in my build. Any ideas? I will post the script below.
local primarypart = script.Parent.main
for i, v in pairs(script.Parent:GetChildren()) do
print(v.Name)
local weld = Instance.new("Weld", v)
weld.C0 = primarypart.CFrame:inverse()
weld.Part0 = primarypart
weld.C1 = v.CFrame:inverse()
weld.Part1 = v
end
Thanks for the help!
Edit:
I've just gotten it to work by specifically welding that part before welding the rest of the model. Why would this be the case?
New Script:
local primarypart = script.Parent.main
script.Parent:WaitForChild("OJ")
local ojweld = Instance.new("Weld", script.Parent.OJ)
ojweld.C0 = primarypart.CFrame:inverse()
ojweld.Part0 = primarypart
ojweld.C1 = script.Parent.OJ.CFrame:inverse()
ojweld.Part1 = script.Parent.OJ
for i, v in pairs(script.Parent:GetChildren()) do
print(v.Name)
local weld = Instance.new("Weld", v)
weld.C0 = primarypart.CFrame:inverse()
weld.Part0 = primarypart
weld.C1 = v.CFrame:inverse()
weld.Part1 = v
end
