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

How would I individually rename the children of a part?

I'm trying to rename 13 motors so that I can further script them to make a custom character. How would I change the names one by one, descending the list of children?

local Body = script.Parent
	Body.PrimaryPart = Body.HumanoidRootPart

	for i=1, 13 do 
		local M = Instance.new("Motor6D") 
		M.Parent = Body.Chest
	end

		local Z = Body.Chest:GetChildren() 

1 answer

✓ Accepted answer

To give each motor a unique name, you must do this:

local Body = script.Parent
    Body.PrimaryPart = Body.HumanoidRootPart

    for i=1, 13 do 
        local M = Instance.new("Motor6D") 
        M.Parent = Body.Chest
	M.Name = "Motor" .. i -- 'i' gets the number of loops
    end

        local Z = Body.Chest:GetChildren()

This script will return a Motor named Motor then whatever id in the loop it is.

For example on the sixth loop, the Motor will be named "Motor6"

Sincerely,

jmanrock123

P.S. I HOPE THIS HELPED <3

2 comments

0

Thanks a lot :)

0

No Problem :)

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