RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"script for chess board as a GUI"
-- This is a basic example of a chess board GUI, you'll need to add your own logic for piece movement and game rules -- LocalScript inside a ScreenGui local boardSize = 8 local tileSize = 50 local board = Instance.new("Frame") board.Parent = script.Parent board.Size = UDim2.new(0, boardSize * tileSize, 0, boardSize * tileSize) board.Position = UDim2.new(0.5, -boardSize * tileSize / 2, 0.5, -boardSize * tileSize / 2) board.BackgroundColor3 = Color3.fromRGB(0, 0, 0) board.BorderSizePixel = 0 for i = 1, boardSize do for j = 1, boardSize do local tile = Instance.new("TextButton") tile.Parent = board tile.Size = UDim2.new(0, tileSize, 0, tileSize) tile.Position = UDim2.new(0, (i - 1) * tileSize, 0, (j - 1) * tileSize) tile.BorderSizePixel = 0 tile.Text = "" if (i + j) % 2 == 0 then tile.BackgroundColor3 = Color3.fromRGB(255, 255, 255) else tile.BackgroundColor3 = Color3.fromRGB(100, 100, 100) end tile.MouseButton1Click:Connect(function() print("Tile clicked: (" .. i .. ", " .. j .. ")") -- Add your own logic for piece movement and game rules here end) end end