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

How to clone a part and have a script inside it run?

Asked by 4 years ago
Edited 4 years ago

I have a mesh part inside of ReplicatedFirst with a simple script attached:

print("Hello world!")

while true do
    print("Hello world!")
    wait(1)
end

However, when I clone it into workspace, it doesn't run. I don't understand why. What am I doing wrong?

Edit:

I tried to set the script's Disabled property to True and then after I cloned the part, set it back to false, but it still didn't run:

This is the function I am using to spawn the meshPart

local function CreateNewPart(partToCreate, position)
    local copy = partToCreate:Clone()
    copy.CFrame = CFrame.new()
    copy.Anchored = true
    copy.CanCollide = true
    copy.Position = position
    copy.Orientation = Vector3.new(0,0,0)
    copy.Parent = platformsFolder
    copy.Script.Disabled = false
    print(copy.Script.Disabled)
    return copy 
end

The output from the print() is "false"

0
You can create the script inside the block and activate its "Disabled" property, then when you clone the Part with a script you deactivate the Disabled of the Script that is inside the Part xmaanzach 28 — 4y
0
It didn't work. I'll edit my question to reflect this User#34187 8 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You can create the script inside the block and activate its "Disabled" property, then when you clone the Part with a script you deactivate the Disabled of the Script that is inside the Part

Ad

Answer this question