The script only welds the copied model to the right leg, but not the left, here is the script:
-- Begin Function function onTouched(hit) -- RightLeg local RightLeg = hit.Parent["Right Leg"] if hit.Parent:findFirstChild("Humanoid") ~= nil and RightLeg:findFirstChild("RocketBoot") == nil then local g = game.Lighting.RocketBoot:Clone() g.Parent = RightLeg local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" or C[i].ClassName == "UnionOperation" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = RightLeg Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0, 0.05) * CFrame.fromEulerAnglesXYZ(0, 0, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i]:IsA("Part") then h[i].Anchored = false h[i].CanCollide = false h[i].TopSurface = "SmoothNoOutlines" h[i].BottomSurface = "SmoothNoOutlines" h[i].LeftSurface = "SmoothNoOutlines" h[i].RightSurface = "SmoothNoOutlines" h[i].FrontSurface = "SmoothNoOutlines" h[i].BackSurface = "SmoothNoOutlines" end end end --LeftLeg local LeftLeg = hit.Parent["Left Leg"] if hit.Parent:findFirstChild("Humanoid") ~= nil and LeftLeg:findFirstChild("RocketBoot") == nil then local g = game.Lighting.RocketBoot:Clone() g.Parent = LeftLeg local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" or C[i].ClassName == "UnionOperation" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = RightLeg Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0, 0.05) * CFrame.fromEulerAnglesXYZ(0, 0, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i]:IsA("Part") then h[i].Anchored = false h[i].CanCollide = false h[i].TopSurface = "SmoothNoOutlines" h[i].BottomSurface = "SmoothNoOutlines" h[i].LeftSurface = "SmoothNoOutlines" h[i].RightSurface = "SmoothNoOutlines" h[i].FrontSurface = "SmoothNoOutlines" h[i].BackSurface = "SmoothNoOutlines" end end end end -- Ending first function script.Parent.Touched:connect(onTouched)
They're at this place: http://www.roblox.com/Steampunk-place?id=296134153
And this is the output: `20:10:50.007 - Right Leg is not a valid member of Model
20:10:50.008 - Script 'Workspace.TheButton.Script', Line 5
20:10:50.009 - Stack End`
I believe the error you've showed us is misleading (not blaming you) -- that error suggests that hit.Parent has no Right Leg (which is easy enough to do -- any non-character model that comes into contact with it will cause the script to error).
I'm not sure as to the actual cause of your problem, but if you use functions to clean up your duplicate code, you might find it easier to debug (ex. by putting print statements through it). Further, if you find a bug, you then only have to change it in the one place, rather than two.
Also, you can remove the error you did find by using :FindFirstChild to get the Right/Left legs (and simply not doing that leg if it doesn't exist).
function WeldBootToLeg(leg) --lines 6 - 39 here end function onTouched(hit) -- RightLeg local RightLeg = hit.Parent:FindFirstChild("Right Leg") if RightLeg and hit.Parent:FindFirstChild("Humanoid") ~= nil and RightLeg:FindFirstChild("RocketBoot") == nil then WeldBootToLeg(RightLeg) end --LeftLeg local LeftLeg = hit.Parent:FindFirstChild("Left Leg") if LeftLeg and hit.Parent:FindFirstChild("Humanoid") ~= nil and LeftLeg:FindFirstChild("RocketBoot") == nil then WeldBootToLeg(LeftLeg) end end script.Parent.Touched:connect(onTouched)
Either another error will pop up (allowing you to address that one), or nothing will show up. If the latter, then start adding print
statements (probably in the WeldBootToLeg
function) to see which lines are running. ex, you might put print(leg, #)
(replacing '#' with a unique number (1,2,...) so that you know which print statements are running). Try to not put any print statements inside for loops that will iterate a lot of times, or else you'll flood your Output window.