nvm 1 sec im making my own gui
- User
nvm 1 sec im making my own gui
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
nvm 1 sec im making my own gui
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Alright, no problem at all! Designing your own GUI is a great way to make your game unique.
Since you'll be making the GUI yourself, I'll provide you with a cleaner, more focused script that handles only the core game logic:
WinTrigger part.This script will go into a LocalScript in StarterPlayerScripts.
Before you add the script, you need to create your GUI elements in Roblox Studio:
In the StarterGui service in the Explorer, insert a ScreenGui. You can name it whatever you want, e.g., MyGameUI.
Inside your ScreenGui, create two TextLabel instances:
SpeedDisplay).WinsDisplay).Customize their appearance (font, size, color, position, background, icons, etc.) to your liking. Just make sure they are TextLabels.
Example Hierarchy:
StarterGui
└─ MyGameUI (ScreenGui)
└─ SpeedDisplay (TextLabel)
└─ WinsDisplay (TextLabel)
Now, create a LocalScript inside StarterPlayerScripts and paste the following code into it.
Location: StarterPlayer → StarterPlayerScripts → GameLogicScript (or any name you prefer)
-- LocalScript: GameLogicScript (Place this in StarterPlayerScripts)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
-- IMPORTANT: Adjust these paths to match your GUI's structure and names
-- Example: playerGui:WaitForChild("YourScreenGuiName"):WaitForChild("YourSpeedTextLabelName")
local playerGui = player:WaitForChild("PlayerGui")
local yourScreenGui = playerGui:WaitForChild("MyGameUI") -- <<< CHANGE 'MyGameUI' to your ScreenGui's name
local speedTextLabel = yourScreenGui:WaitForChild("SpeedDisplay") -- <<< CHANGE 'SpeedDisplay' to your Speed TextLabel's name
local winsTextLabel = yourScreenGui:WaitForChild("WinsDisplay") -- <<< CHANGE 'WinsDisplay' to your Wins TextLabel's name
-- Initial values
local currentSpeed = 16.0
local wins = 0
local speedIncreaseConnection = nil -- This will hold the connection for the speed update loop
-- Function to set up speed and win tracking for a new character (or respawned character)
local function setupPlayerCharacter(character)
local humanoid = character:WaitForChild("Humanoid")
-- Reset speed when character spawns/respawns
currentSpeed = 16.0
humanoid.WalkSpeed = currentSpeed
-- Update GUI on spawn
speedTextLabel.Text = "Speed: " .. string.format("%.1f", currentSpeed)
winsTextLabel.Text = "Wins: " .. wins -- Display current wins, persists across respawns
-- Disconnect any existing speed increase loop (important for respawns)
if speedIncreaseConnection then
speedIncreaseConnection:Disconnect()
end
-- Start the speed increase loop using Heartbeat for smooth updates
-- Heartbeat fires every frame, deltaTime is the time elapsed since the last frame
speedIncreaseConnection = RunService.Heartbeat:Connect(function(deltaTime)
if humanoid and humanoid.Health > 0 then -- Only update if humanoid exists and is alive
currentSpeed = currentSpeed + (0.1 * deltaTime) -- Increase by 0.1 per second
humanoid.WalkSpeed = currentSpeed
speedTextLabel.Text = "Speed: " .. string.format("%.1f", currentSpeed)
else
-- If humanoid is no longer valid (e.g., player died), stop the loop
speedIncreaseConnection:Disconnect()
end
end)
end
-- Connect the setup function to when the player's character is added (first spawn and respawns)
player.CharacterAdded:Connect(setupPlayerCharacter)
-- Call it immediately if the character already exists (e.g., when joining a game already in progress)
if player.Character then
setupPlayerCharacter(player.Character)
end
-- Win detection system
-- This listens for any new parts added to the workspace (like a dynamically spawned 'WinTrigger')
workspace.DescendantAdded:Connect(function(descendant)
-- Check if the added part is named "WinTrigger" and is a BasePart
if descendant.Name == "WinTrigger" and descendant:IsA("BasePart") then
local winTriggerConnection -- Store the touch connection for this specific trigger
winTriggerConnection = descendant.Touched:Connect(function(partTouched)
-- Check if the part touching is part of the player's character
if partTouched:IsA("BasePart") and partTouched.Parent == player.Character then
wins = wins + 1 -- Increment wins
winsTextLabel.Text = "Wins: " .. wins -- Update GUI
-- Clean up: Disconnect the touch event and destroy the trigger
-- Use task.spawn to avoid blocking the current connection or causing issues
task.spawn(function()
winTriggerConnection:Disconnect() -- Stop listening for touches on this trigger
task.wait(0.1) -- Small delay before destroying to ensure win registers
if descendant and descendant.Parent then -- Check if it still exists before attempting to destroy
descendant:Destroy()
end
end)
end
end)
end
end)
-- Optional: Create a sample "WinTrigger" part for easy testing in Studio
-- This part will be created automatically when you test in Roblox Studio,
-- so you don't have to manually place it every time.
if RunService:IsStudio() then
task.wait(2) -- Wait a couple seconds for the game to load
local testWinTrigger = Instance.new("Part")
testWinTrigger.Name = "WinTrigger" -- VERY IMPORTANT: Must be named "WinTrigger"
testWinTrigger.Size = Vector3.new(10, 10, 10)
testWinTrigger.Position = Vector3.new(0, 5, 30) -- Place it 30 studs in front of default spawn
testWinTrigger.Anchored = true
testWinTrigger.Transparency = 0.7 -- Make it slightly see-through
testWinTrigger.CanCollide = false -- Player can walk through it
testWinTrigger.BrickColor = BrickColor.new("Bright green")
testWinTrigger.Parent = workspace -- Add it to the game world
end
yourScreenGui, speedTextLabel, and winsTextLabel. Make sure the names MyGameUI, SpeedDisplay, and WinsDisplay match exactly what you named your ScreenGui and TextLabels in StarterGui.0.1 * deltaTime to the player's WalkSpeed every frame (Heartbeat). deltaTime ensures the speed increase is consistent regardless of the player's frame rate.Part in your workspace and name it exactly WinTrigger.WinTrigger part, their win count will increase, and the WinTrigger part will be destroyed to prevent multiple wins from the same trigger.WinTrigger parts in your game, or you can have other server-side scripts spawn them dynamically (e.g., at the end of a race track).Wins count will persist.WinTrigger 30 studs in front of your spawn point when you test in Roblox Studio. This is just for quick testing and won't appear in the published game.Now you have full control over the look of your GUI, while the script handles all the backend logic for speed and wins! Let me know if you have any more questions or need tweaks!