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

Can't Move Character?

Asked by 8 years ago

script.Parent.MouseClick:connect(function(playerWhoClicked) local person = game.Players:FindFirstChild(playerWhoClicked.Name) local handle = script.Parent.Parent local bodpos= Instance.new("BodyGyro") bodpos.Parent= person.Character["Torso"] person.Character:GetChildren().Position = Vector3.new(handle.Position,handle.Position,handle.Position) end)

i couldn't find any other way to move a body part (without breaking/killing the character) or the model. GetChildren() does not seem to be working for this so Any advice ?

0
Please use code blocks next time you post code in a question. To do this, click the blue Lua logo icon above the text box. Link150 1355 — 8y

1 answer

Log in to vote
2
Answered by
Unlimitus 120
8 years ago

First off, GetChildren() is not what you think it is. GetChildren returns a table with the children of the instance that you called the GetChildren() function on. To change a property of all things inside an instance, you have to use an "pairs" loop. Which is:

for i, v in pairs(something:GetChildren()) do -- "i" is the current index, v is the variable, and something that you set it to.
    -- do something to v
end

Second, BodyGyro is for rotation, not position.

Third, if your intention is to teleport the player, you don't need to move every single part, you can just move the Torso via CFrame.

Hope this helps.

0
Cool answer :3 User#11440 120 — 8y
Ad

Answer this question