I have script that copies a GUI into a plyers GUi when clicked. Works the first time but this pops up when you click again.

18:29:43.464 - The Parent property of CardGiverGui is locked, current parent: NULL, new parent PlayerGui 18:29:43.465 - Stack Begin 18:29:43.465 - Script 'Workspace.Part.Script', Line 6 18:29:43.466 - Stack End

Here is my script:

MainScreen = script.Parent.GUI.CardGiverGui

function onClicked()
	MainScreen:Clone()
	MainScreen.Parent = game.Players.LocalPlayer.PlayerGui
end


script.Parent.ClickDetector.MouseClick:connect(onClicked)

2 comments

0

You're setting the parent of the original "MainScreen" to the LocalPlayer, and not the clone; the Clone function clones the instance & returns it, it doesn't change the variable or make it the cloned version; you could do

0

child:Clone().Parent = bleh to counter this though, as it'll set the cloned one to the parent; note that you either need to set the parent when you first clone, or set up a new variable for the clone, otherwise it wont go as planned. :P Dw, we're all human after all. :)