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

No error in studio when welding but errors in actual game?

Asked by 6 years ago

Alright, I have this script that spawns in a model then welds it together. The error comes in when the humanoidrootpart is post to be welded. It says that the humanoidrootpart isn't apart of the model, but it clearly is. What makes this one really confusing to me is that, the script works perfectly fine in play solo but, doesn't work in the actual game.

Here is the script in question.

B = script.Parent



local weld1 = Instance.new("Motor6D", B["Left Foot"])
weld1.Part0 = weld1.Parent
weld1.Part1 = B["Lower Left Leg"]
weld1.C0 = CFrame.new(0, 6.95, 1.8)*CFrame.new(0, -math.pi/5, 0)
local weld2 = Instance.new("Motor6D", B["Lower Left Leg"])
weld2.Part0 = weld2.Parent
weld2.Part1 = B["Upper Left Leg"]
weld2.C0 = CFrame.new(0, 1.72 + 7.7 + 0.592, 0 + 0.181)*CFrame.new(0, -math.pi/5, 0)
local weld3 = Instance.new("Motor6D", B["Upper Left Leg"])
weld3.Part0 = weld3.Parent
weld3.Part1 = B["Lower Torso"]
weld3.C0 = CFrame.new(0 + 3.97,0 + 8.541,0)*CFrame.new(0, -math.pi/5, 0)

local weld4 = Instance.new("Motor6D", B["Right Foot"])
weld4.Part0 = weld4.Parent
weld4.Part1 = B["Lower Right Leg"]
weld4.C0 = CFrame.new(0, 6.95, 1.8)*CFrame.new(0, -math.pi/5, 0)
local weld5 = Instance.new("Motor6D", B["Lower Right Leg"])
weld5.Part0 = weld5.Parent
weld5.Part1 = B["Upper Right Leg"]
weld5.C0 = CFrame.new(0,10.012, -0.181)*CFrame.new(0, -math.pi/5, 0)
local weld6 = Instance.new("Motor6D", B["Upper Right Leg"])
weld6.Part0 = weld6.Parent
weld6.Part1 = B["Lower Torso"]
weld6.C0 = CFrame.new(-3.97,8.541,0)*CFrame.new(0, -math.pi/5, 0)


local weld7 = Instance.new("Motor6D", B["Left Hand"])
weld7.Part0 = weld7.Parent
weld7.Part1 = B["Lower Left Arm"]
weld7.C0 = CFrame.new(0,9.25,0)*CFrame.fromEulerAnglesXYZ(0,0,0)
local weld8 = Instance.new("Motor6D", B["Lower Left Arm"])
weld8.Part0 = weld8.Parent
weld8.Part1 = B["Upper Left Arm"]
weld8.C0 = CFrame.new(0,17.8,0)*CFrame.fromEulerAnglesXYZ(0,0,0)
local weld9 = Instance.new("Motor6D", B["Upper Left Arm"])
weld9.Part0 = weld9.Parent
weld9.Part1 = B["Upper Torso"]
weld9.C0 = CFrame.new(9,-4.6,0)*CFrame.fromEulerAnglesXYZ(0,0,math.pi/4)

local weld10 = Instance.new("Motor6D", B["Right Hand"])
weld10.Part0 = weld10.Parent
weld10.Part1 = B["Lower Right Arm"]
weld10.C0 = CFrame.new(0,9.25,0)*CFrame.fromEulerAnglesXYZ(0,0,0)
local weld11 = Instance.new("Motor6D", B["Lower Right Arm"])
weld11.Part0 = weld11.Parent
weld11.Part1 = B["Upper Right Arm"]
weld11.C0 = CFrame.new(0,17.8,0)*CFrame.fromEulerAnglesXYZ(0,0,0)
local weld12 = Instance.new("Motor6D", B["Upper Right Arm"])
weld12.Part0 = weld12.Parent
weld12.Part1 = B["Upper Torso"]
weld12.C0 = CFrame.new(-9,-4.6,0)*CFrame.fromEulerAnglesXYZ(0,0,math.pi/4)

local weld13 = Instance.new("Weld", B["Head"])
weld13.Part0 = weld13.Parent
weld13.Part1 = B["Weld to Head"]
weld13.C0 = CFrame.new(0,-.48,-2)*CFrame.fromEulerAnglesXYZ(0,0,0)
local weld14 = Instance.new("Weld", B["Weld to Head"])
weld14.Part0 = weld14.Parent
weld14.Part1 = B["Weld to Torso"]
weld14.C0 = CFrame.new(0,-6.12,-0.73)*CFrame.fromEulerAnglesXYZ(0,-math.pi,0)
local weld16 = Instance.new("Motor6D", B["Weld to Torso"])
weld16.Part0 = weld16.Parent
weld16.Part1 = B["Upper Torso"]
weld16.C0 = CFrame.new(0,-12.48,0)*CFrame.fromEulerAnglesXYZ(0,0,math.pi/4)

local weld15 = Instance.new("Motor6D", B["Upper Torso"])
weld15.Part0 = weld15.Parent
weld15.Part1 = B["Lower Torso"]
weld15.C0 = CFrame.new(-7,-7,0)*CFrame.fromEulerAnglesXYZ(0,0,-math.pi/4)

local weld17 = Instance.new("Motor6D", B["Upper Torso"])
weld17.Part0 = weld17.Parent
weld17.Part1 = B.HumanoidRootPart
weld17.C0 = CFrame.new(0,0,0)*CFrame.fromEulerAnglesXYZ(0,0,-math.pi/4)

And here is proof that the HumanoidRootPart is in the model.

https://gyazo.com/5b1dbdda5f21ba89e2ac7628343c2a06

Also should mention that I have a script that spawns the model into workspace, then it breaks. (In actual game not studio.)

The model itself is in ReplicatedStorage.

Also the error just in case it's needed.

https://gyazo.com/ccfcfbad977387a149303da590ffce4a

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
6 years ago

:WaitForChild() is your best friend. Read up on it.

https://wiki.roblox.com/index.php?title=API:Class/Instance/WaitForChild

0
Thank you so much, if you wouldn't mind could tell me why that made it work in actual game? YourMajesty_Kami 1 — 6y
1
Because the HumanoidRootPart Had not loaded yet and the script was already firing causing it to error, but using WaitForChild waits for the object to be loaded in. Prestory 1395 — 6y
Ad

Answer this question