How to make a button clone a GUI

Hello! I am trying to make a button clone a GUI that is in the ServerStorage, but i cant figure out how can i do this, also the button uses click detector. Please help me, also keep în mind that im new to scripting and coding so if anyone could help me i would appreciate alot

local ServerStorage = game:GetService("ServerStorage")

local ButtonToClone = ServerStorage.Button -- the thing to clone
local Button = game.Workspace.Part.ClickDetector -- the click detector

Button.MouseClick:Connect(function() -- player clicks the ClickDetector
	ButtonToClone:Clone().Parent = game.Workspace -- The cloned thing goes to workspace
end)
2 Likes

Just a note, try to avoid parenting the clone directly like that. Instead do -
[In this case it doesnt really matter, since you dont really do any connects here, but still important note]

local clone = ButtonToClone:Clone()
clone.Parent = game.Workspace

You can read about it Here