I got an error saying:
Torso is not a valid member of Model
13:29:25.072 - Script 'Players.Player1.PlayerGui.AnimatiomThing', Line 8
13:29:25.073 - Stack End
Why did I get this error if i'm using the "WaitForChild" method and how do I fix it?
LocalScript:
Player = game.Players.LocalPlayer Character = Player.Character ----------------------------------------- if not Character or Character.Parent == nil then Character = Player.CharacterAdded:wait() end ----------------------------------------- Torso = Character:WaitForChild(Character.Torso) Mouse = Player:GetMouse() Clicked = false ----------------------------------------- function MakeWelds() local Arms = {Character["Left Arm"], Character["Right Arm"] } local ArmWelds = {} for i,v in pairs (Arms) do local Weld = Instance.new("Weld",Torso) Weld.Name = v.Name.." Weld" Weld.Part0 = Torso Weld.Part1 = v ArmWelds[i] = Weld--Adds Weld to ArmsWeld table end return ArmWelds end Weld = MakeWelds() Weld[1].C0 = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(0.5,2.5,1) Weld[2].C0 = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(0.5,-2.5,-1) Mouse.Button1Down:connect(function() if not Clicked then Clicked = true Weld[1].C0 = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(1,5,2) Weld[2].C0 = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(1,-5,-2) wait(0.2) Weld[1].C0 = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(0.5,2.5,1) Weld[2].C0 = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(0.5,-2.5,-1) Clicked = false end end) ---------------------------------------
Instead of passing in an object (that may not exist) to WaitForChild:
Torso = Character:WaitForChild(Character.Torso)
You should be passing in the string "Torso"
Torso = Character:WaitForChild("Torso")
Player = game.Players.LocalPlayer Character = Player.Character ----------------------------------------- repeat wait() until Character and Character.Torso ----------------------------------------- Torso = Character.Torso Mouse = Player:GetMouse() Clicked = false ----------------------------------------- function MakeWelds() local Arms = {Character["Left Arm"], Character["Right Arm"] } local ArmWelds = {} for i,v in pairs (Arms) do local Weld = Instance.new("Weld",Torso) Weld.Name = v.Name.." Weld" Weld.Part0 = Torso Weld.Part1 = v ArmWelds[i] = Weld--Adds Weld to ArmsWeld table end return ArmWelds end Weld = MakeWelds() Weld[1].C0 = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(0.5,2.5,1) Weld[2].C0 = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(0.5,-2.5,-1) Mouse.Button1Down:connect(function() if not Clicked then Clicked = true Weld[1].C0 = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(1,5,2) Weld[2].C0 = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(1,-5,-2) wait(0.2) Weld[1].C0 = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(0.5,2.5,1) Weld[2].C0 = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(0.5,-2.5,-1) Clicked = false end end) ---------------------------------------