I made a code that mirrors the Windows GUI based on a windows 11 game I played and I wanted to know if there’s any bugs or things I should add?
Code:
local UIS = game:GetService("UserInputService")
local player = Players.LocalPlayer
local gui = Instance.new("ScreenGui")
gui.Name = "WindowsSystem"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")
local taskbar = Instance.new("Frame")
taskbar.Size = UDim2.new(1, 0, 0, 40)
taskbar.Position = UDim2.new(0, 0, 1, -40)
taskbar.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
taskbar.BorderSizePixel = 0
taskbar.Parent = gui
local startButton = Instance.new("TextButton")
startButton.Size = UDim2.new(0, 120, 1, 0)
startButton.Text = "Windows"
startButton.TextColor3 = Color3.new(1,1,1)
startButton.BackgroundColor3 = Color3.fromRGB(35,35,35)
startButton.BorderSizePixel = 0
startButton.Parent = taskbar
local startMenu = Instance.new("Frame")
startMenu.Size = UDim2.new(0, 260, 0, 300)
startMenu.Position = UDim2.new(0, 0, 1, -340)
startMenu.BackgroundColor3 = Color3.fromRGB(40,40,40)
startMenu.BorderSizePixel = 0
startMenu.Visible = false
startMenu.Parent = gui
local menuLayout = Instance.new("UIListLayout")
menuLayout.Padding = UDim.new(0, 6)
menuLayout.Parent = startMenu
local windowFolder = Instance.new("Folder")
windowFolder.Name = "Windows"
windowFolder.Parent = gui
local function makeDraggable(frame, bar)
local dragging = false
local dragStart
local startPos
bar.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
dragStart = input.Position
startPos = frame.Position
end
end)
bar.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = false
end
end)
UIS.InputChanged:Connect(function(input)
if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
local delta = input.Position - dragStart
frame.Position = startPos + UDim2.new(0, delta.X, 0, delta.Y)
end
end)
end
local function createWindow(title)
local window = Instance.new("Frame")
window.Size = UDim2.new(0, 420, 0, 300)
window.Position = UDim2.new(0.3, 0, 0.2, 0)
window.BackgroundColor3 = Color3.fromRGB(235,235,235)
window.BorderSizePixel = 0
window.Parent = windowFolder
local titleBar = Instance.new("Frame")
titleBar.Size = UDim2.new(1, 0, 0, 32)
titleBar.BackgroundColor3 = Color3.fromRGB(45,45,45)
titleBar.BorderSizePixel = 0
titleBar.Parent = window
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, -40, 1, 0)
titleLabel.Position = UDim2.new(0, 8, 0, 0)
titleLabel.Text = title
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.TextColor3 = Color3.new(1,1,1)
titleLabel.BackgroundTransparency = 1
titleLabel.Parent = titleBar
local closeButton = Instance.new("TextButton")
closeButton.Size = UDim2.new(0, 32, 1, 0)
closeButton.Position = UDim2.new(1, -32, 0, 0)
closeButton.Text = "X"
closeButton.TextColor3 = Color3.new(1,1,1)
closeButton.BackgroundColor3 = Color3.fromRGB(170, 50, 50)
closeButton.BorderSizePixel = 0
closeButton.Parent = titleBar
closeButton.MouseButton1Click:Connect(function()
window:Destroy()
end)
makeDraggable(window, titleBar)
return window
end
local function createStartApp(name)
local button = Instance.new("TextButton")
button.Size = UDim2.new(1, -12, 0, 36)
button.Position = UDim2.new(0, 6, 0, 0)
button.Text = name
button.TextColor3 = Color3.new(1,1,1)
button.BackgroundColor3 = Color3.fromRGB(60,60,60)
button.BorderSizePixel = 0
button.Parent = startMenu
button.MouseButton1Click:Connect(function()
startMenu.Visible = false
createWindow(name)
end)
end
createStartApp("Notepad")
createStartApp("Explorer")
createStartApp("Settings")
startButton.MouseButton1Click:Connect(function()
startMenu.Visible = not startMenu.Visible
end)
