Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can't Move Character?

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 ?

1 comment

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.

1 answer

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.

1 comment

0

Cool answer :3

This discussion is preserved as it was. New answers, comments, and votes are closed.