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

Why is it saying that the Torso isn't a valid part of model?

Asked by 10 years ago

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)


---------------------------------------

2 answers

Log in to vote
3
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

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")
Ad
Log in to vote
1
Answered by 10 years ago
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)


---------------------------------------


0
It's isn't working when I create a server with 2 players and the error is gone. kevinnight45 550 — 10y

Answer this question