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

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

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"

2 comments

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

0

It didn't work. I'll edit my question to reflect this

1 answer

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

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