-- remember to use UDim.fromScale() instead of UDim.new() for the position and size of the frame for cross platform support if used with other screen sizes -- made by turquoiz1772 -- minimising stuff local isMinimised = false -- flag for checking if the frame is minimised local lastPos -- used for putting the frame back to where it was when maximised local isClosed = false -- flag for checking if the GUI was closed by user local frame, title, closebutton, minimisebutton -- add ui element definitions here for entire script access local testButton -- example, remove if you want local createdInstances = {} local player = game.Players.LocalPlayer local playergui = player.PlayerGui local screenguiname = "TurquoizTemplate" -- internal name of the screengui local screengui = playergui:FindFirstChild(screenguiname) local framename = "Frame" -- internal name of the frame local titletext = "Turquoiz Template" -- title text local function makeDraggable(uitomodify) -- use to make draggable ui local dragdetector = Instance.new("UIDragDetector") dragdetector.Parent = uitomodify end local function visibleToggle(value) title.Visible = value -- add the rest of the ui elements you want to be invisible when minimised testButton.Visible = value end local function minimise() -- minimise function lastPos = frame.Position frame.Size = UDim2.fromScale(0.00984, 0.03472) frame.Position = UDim2.fromScale(0, 0.6) -- position to snap to when minimised minimisebutton.Position = UDim2.fromScale(0, 0.5) minimisebutton.Size = UDim2.fromScale(1, 0.5) minimisebutton.Text = "+" closebutton.Position = UDim2.fromScale(0, 0) closebutton.Size = UDim2.fromScale(1, 0.5) visibleToggle(false) isMinimised = true end local function unminimise() -- unminimise function frame.Size = UDim2.fromScale(0.15, 0.3) if lastPos then frame.Position = lastPos end minimisebutton.Position = UDim2.fromScale(0.95, 0.06) minimisebutton.Size = UDim2.fromScale(0.04, 0.04) minimisebutton.Text = "-" closebutton.Position = UDim2.fromScale(0.95, 0.02) closebutton.Size = UDim2.fromScale(0.04, 0.04) visibleToggle(true) isMinimised = false end local function makeButton(name, text, position, size, parent, zindex) -- helper to make text buttons with various properties, you can change as needed local button = Instance.new("TextButton") button.Parent = parent button.Text = text button.Position = position button.Size = size button.Name = name button.ZIndex = zindex table.insert(createdInstances, button) return button end local function makeTextBox(name, text, position, size, parent, zindex) -- helper to make text boxes with various properties, you can change as needed local textbox = Instance.new("TextBox") textbox.Parent = parent textbox.Text = text textbox.Position = position textbox.Size = size textbox.Name = name textbox.ZIndex = zindex table.insert(createdInstances, textbox) return textbox end local function create() screengui = Instance.new("ScreenGui") screengui.Parent = playergui screengui.Name = screenguiname screengui.IgnoreGuiInset = true frame = Instance.new("Frame") -- add ui here, or create more frames for extra windows frame.Parent = screengui -- put in screengui frame.Name = framename frame.BackgroundColor3 = Color3.fromRGB(0, 255, 255) frame.Size = UDim2.fromScale(0.15, 0.3) -- define size to make visible frame.Position = UDim2.fromScale(0.2, 0.6) -- starts from top left by default makeDraggable(frame) -- use on ui to make draggable title = Instance.new("TextLabel") -- default title has a size of UDim2.fromScale(0, 0) you have to change it for the background to be visible title.Parent = frame title.Position = UDim2.fromScale(0.5, 0.05) title.TextSize = 16 title.Text = titletext title.ZIndex = 1 title.BackgroundTransparency = 1 closebutton = Instance.new("TextButton") closebutton.Parent = frame closebutton.Position = UDim2.fromScale(0.95, 0.02) closebutton.Text = "X" closebutton.BackgroundColor3 = Color3.fromRGB(255, 0, 0) closebutton.ZIndex = 2 closebutton.Size = UDim2.fromScale(0.04, 0.04) closebutton.Activated:Connect(function() -- close button functionality isClosed = true -- mark as closed by user screengui:Destroy() end) minimisebutton = Instance.new("TextButton") minimisebutton.Parent = frame minimisebutton.Position = UDim2.fromScale(0.95, 0.06) minimisebutton.Text = "-" minimisebutton.BackgroundColor3 = Color3.fromRGB(255, 255, 0) minimisebutton.ZIndex = 2 minimisebutton.Size = UDim2.fromScale(0.04, 0.04) minimisebutton.Activated:Connect(function() -- controls minimising and unminimising if isMinimised then unminimise() else minimise() end end) local function reload() -- change to global function if you want local currentPos = nil if frame and frame.Parent then currentPos = frame.Position if isMinimised then print("Unminimising...") unminimise() -- unminimise. obviously print("Done.") end end print("Destroying created buttons...") for _, instance in pairs(createdInstances) do -- destroy buttons made by helper before destroying screengui if instance and instance.Parent then instance:Destroy() instance = nil end end print("Done.") print("Clearing table...") table.clear(createdInstances) print("Done.") if screengui and screengui.Parent then -- destroy screengui screengui:Destroy() end print("Recreating...") create() -- recreate print("Done.") print("Moving frame...") if currentPos and frame then -- move frame back frame.Position = currentPos end print("Done.") print("Reloaded Successfully.") end testButton = makeButton("TestButton", "Test Button", UDim2.fromScale(0.05, 0.2), UDim2.fromScale(0.9, 0.2), frame, 2) -- example, remove if you want testButton.Activated:Connect(function() -- example, remove if you want reload() print("Reloaded") end) end local function onCharacterAdded(character) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:Connect(function() if isMinimised then return end if frame then lastPos = frame.Position end end) if frame then frame:Destroy() end if screengui then screengui:Destroy() end if not isClosed then create() if lastPos then frame.Position = lastPos end if isMinimised then minimise() end end end if screengui then screengui:Destroy() end create() -- handle the character if player.Character then onCharacterAdded(player.Character) end -- hook to spawn and respawn player.CharacterAdded:Connect(onCharacterAdded)