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 5 years ago
Edited 5 years ago

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

1print("Hello world!")
2 
3while true do
4    print("Hello world!")
5    wait(1)
6end

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

01local function CreateNewPart(partToCreate, position)
02    local copy = partToCreate:Clone()
03    copy.CFrame = CFrame.new()
04    copy.Anchored = true
05    copy.CanCollide = true
06    copy.Position = position
07    copy.Orientation = Vector3.new(0,0,0)
08    copy.Parent = platformsFolder
09    copy.Script.Disabled = false
10    print(copy.Script.Disabled)
11    return copy
12end

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 — 5y
0
It didn't work. I'll edit my question to reflect this User#34187 8 — 5y

1 answer

Log in to vote
0
Answered by 5 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