vreau sa fac un gui care sa fie un timer pe roblox
- User
vreau sa fac un gui care sa fie un timer pe roblox
Assistant
Pot să te ajut să creezi un timer GUI pentru Roblox! Iată un exemplu complet:
Script pentru Timer GUI
Primul pas este să creezi interfața în StarterGui:
- În Roblox Studio, du-te la StarterGui
- Adaugă un ScreenGui
- În ScreenGui, adaugă un Frame (pentru fundal)
- În Frame, adaugă un TextLabel (pentru afișarea timpului)
Apoi, adaugă acest script într-un LocalScript în ScreenGui:
local screenGui = script.Parent local frame = screenGui:WaitForChild("Frame") local timeLabel = frame:WaitForChild("TextLabel") -- Configurare timer local totalTime = 60 -- Timpul în secunde local currentTime = totalTime local timerActive = false -- Funcție pentru formatarea timpului local function formatTime(seconds) local mins = math.floor(seconds / 60) local secs = seconds % 60 return string.format("%02d:%02d", mins, secs) end -- Funcție pentru pornirea timer-ului local function startTimer() timerActive = true while timerActive and currentTime > 0 do timeLabel.Text = formatTime(currentTime) wait(1) currentTime = currentTime - 1 end if currentTime <= 0 then timeLabel.Text = "00:00" -- Aici poți adăuga ce se întâmplă când timpul expiră print("Timpul a expirat!") end end -- Pornește timer-ul automat startTimer()Exemplu mai avansat cu butoane Start/Stop/Reset:
local screenGui = script.Parent local frame = screenGui:WaitForChild("Frame") local timeLabel = frame:WaitForChild("TextLabel") local startButton = frame:WaitForChild("StartButton") local stopButton = frame:WaitForChild("StopButton") local resetButton = frame:WaitForChild("ResetButton") local totalTime = 60 local currentTime = totalTime local timerActive = false local function formatTime(seconds) local mins = math.floor(seconds / 60) local secs = seconds % 60 return string.format("%02d:%02d", mins, secs) end local function updateDisplay() timeLabel.Text = formatTime(currentTime) end -- Inițializare afișaj updateDisplay() -- Timer loop spawn(function() while true do if timerActive and currentTime > 0 then wait(1) currentTime = currentTime - 1 updateDisplay() if currentTime <= 0 then timerActive = false -- Acțiuni când timpul expiră end else wait(0.1) end end end) -- Butoane startButton.MouseButton1Click:Connect(function() timerActive = true end) stopButton.MouseButton1Click:Connect(function() timerActive = false end) resetButton.MouseButton1Click:Connect(function() timerActive = false currentTime = totalTime updateDisplay() end)Proprietăți recomandate pentru GUI:
Pentru Frame:
- Size: {0.3, 0}, {0.2, 0}
- Position: {0.35, 0}, {0.1, 0}
- BackgroundColor3: Color3.new(0.2, 0.2, 0.2)
- BorderSizePixel: 0
Pentru TextLabel:
- Size: {1, 0}, {0.6, 0}
- Position: {0, 0}, {0, 0}
- TextScaled: true
- TextColor3: Color3.new(1, 1, 1)
- BackgroundTransparency: 1
Dacă vrei să adaugi funcționalități specifice sau ai nevoie de ajutor cu stilizarea, spune-mi!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.