Plugin, script doesn't work after plugin refreshes

What i want to achieve:
Random amount of TextButtons created and parented to a ScrollingFrame. With in the TextButton is a cloned script “ButtonScript”.

Amount of TextButtons are the amount of all scripts in game.

I am also trying to keep the TextButton script separate from the main script.


main script is the “Refresh” button
“Script1” is the TextButton so is “Script2” etc

“ButtonScript” is cloned into all the TextButtons
ButtonScript is not running

The issue:
The issue still remains that any cloned script after the plugin refreshes will not run.
And if a script is disabled then re-enabled after the plugin refreshes it will not run.

̶I̶ ̶h̶a̶v̶e̶ ̶s̶o̶m̶e̶ ̶u̶s̶e̶ ̶c̶a̶s̶e̶s̶ ̶f̶o̶r̶ ̶c̶l̶o̶n̶i̶n̶g̶ ̶t̶h̶e̶ ̶s̶c̶r̶i̶p̶t̶ ̶i̶n̶ ̶t̶h̶e̶ ̶f̶i̶r̶s̶t̶ ̶p̶l̶a̶c̶e̶ ̶b̶u̶t̶ ̶i̶ ̶c̶a̶n̶’̶t̶ ̶t̶h̶i̶n̶k̶ ̶o̶f̶ ̶o̶n̶e̶ ̶a̶t̶ ̶t̶h̶e̶ ̶c̶u̶r̶r̶e̶n̶t̶ ̶t̶i̶m̶e̶.̶

example code

The code here is an example of the issue.

-- main script
   put this in plugin
print("Create Script")
local run =
local run_Clone = run:Clone()
run_Clone.Name = "Running"
run_Clone.Disabled = false
run_Clone.Parent = script
-- run script
   parent this to main script

I have looked through the devform and could not find a post related to this issue.

1 Like

Whatever you’re describing is pretty abstract. A few more details would be very helpful. What are all these TextButtons for? What purpose do they serve? Is it an editor of some kind? What’s this plugin even do? Is it even relevant that this is a plugin?

It sounds like you ought to use a ModuleScript for this. Or, rather, whatever is instantiating your buttons should connect to their MouseButton1Click events, rather than a script within them.


Just like @Ozzypig said you can simply connect the MouseButton1Click event whenever you create a new textbutton.

For example:

function CreateNewButton() -- Pretend this is your script thats creating random amounts of text buttons
	local NewButton ="TextButton");
	NewButton.Size =,200,0,50);
	NewButton.Parent = script.Parent.ScrollingFrame; -- Parent it to the scrolling frame, etc
	-- In the same script right after you create the textbutton, you can connect MouseButton1Click event to the created button
	NewButton.MouseButton1Click:Connect(function() -- Connect the event to the new button	
		print("You have clicked the button!!");
		-- do what you want here

while wait(3)do -- Lets say your creating text buttons via while loop (please don't actually do this tho)

This is just a rough idea of how you would do it. Hopefully it gives you some insight of what to do!

1 Like

i was trying to put this part in another script

and i realised that i could use a BindableEvent.

I found a solution with the above, but the problem is still there.

Thanks for trying to help me :smiley:

I have anwsered most of the questions.