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

Would it make more sense to create gui elements or clone them out of repl. storage?

I have a script inside a button that created a gui for the player:

local exists = false

script.Parent.MouseButton1Click:Connect(function()
	local JobPanel
	if not exists then
	exists = true
	JobPanel = Instance.new("Frame", script.Parent.Parent.Parent.Parent)
	JobPanel.BackgroundTransparency = 1
	JobPanel.Name = "Job Panel"
	JobPanel.AnchorPoint = Vector2.new(0.5, 0.5)
	JobPanel.Position = UDim2.new(0.5,0,0.5,0)
	JobPanel.Size = UDim2.new(0,800,0,450)
	local Title = Instance.new("TextLabel", JobPanel)
	Title.BackgroundColor3 = Color3.new(255,255,255)
	Title.Size = UDim2.new(0,750,0,30)
	Title.Text = "Job Menu"
	Title.TextScaled = true
	local Close = Instance.new("TextButton", JobPanel)
	Close.BackgroundColor3 = Color3.new(255,53,53)
	Close.Position = UDim2.new(0.938,0,0,0)
	Close.Size = UDim2.new(0,50,0,30)
	Close.Text = "Close"
	Close.MouseButton1Click:Connect(function()
		JobPanel:Destroy()
		exists = false
	end)
	local JobFrame = Instance.new("ScrollingFrame", JobPanel)
	JobFrame.Position = UDim2.new(0,0,0.067,0)
	JobFrame.Size = UDim2.new(0,600,0,420)
	JobFrame.ScrollBarThickness = 3
	local JobInfo = Instance.new("Frame", JobPanel)
	JobInfo.Position = UDim2.new(0.75,0,0.067,0)
	JobInfo.Size = UDim2.new(0,200,0,420)
	local selectAJob = Instance.new("TextLabel", JobInfo)
	selectAJob.Position = UDim2.new(-0.002,0,0,0)
	selectAJob.Size = UDim2.new(0,200,0,50)
	selectAJob.Text = "Select a job."
	end
end)

Is it efficient to just create new instances like that or should I be doing something else?

1 answer

You could make the frame beforehand and set the Visible property.

script.Parent.MouseButton1Click:Connect(function()
	FRAME.Visible = not FRAME.Visible
end)

2 comments

0

anything but this

0

?

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