TimberWoods / src /StarterGui /MainHUD.client.lua
algorembrant's picture
Upload 88 files
0712d5f verified
-- src/StarterGui/MainHUD.client.lua
-- Full in-game HUD: cash display, equipped tool, minimap frame, hotbar, weather indicator
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local Utility = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Utility"))
-- Create ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "MainHUD"
screenGui.ResetOnSpawn = false
screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
screenGui.Parent = player:WaitForChild("PlayerGui")
-- ========== TOP BAR ==========
local topBar = Instance.new("Frame")
topBar.Name = "TopBar"
topBar.Size = UDim2.new(1, 0, 0, 50)
topBar.Position = UDim2.new(0, 0, 0, 0)
topBar.BackgroundColor3 = Color3.fromRGB(20, 25, 30)
topBar.BackgroundTransparency = 0.3
topBar.BorderSizePixel = 0
topBar.Parent = screenGui
local topCorner = Instance.new("UICorner")
topCorner.CornerRadius = UDim.new(0, 0)
topCorner.Parent = topBar
-- Cash Display
local cashFrame = Instance.new("Frame")
cashFrame.Name = "CashFrame"
cashFrame.Size = UDim2.new(0, 200, 0, 40)
cashFrame.Position = UDim2.new(0, 10, 0, 5)
cashFrame.BackgroundColor3 = Color3.fromRGB(40, 120, 40)
cashFrame.BackgroundTransparency = 0.3
cashFrame.BorderSizePixel = 0
cashFrame.Parent = topBar
local cashCorner = Instance.new("UICorner")
cashCorner.CornerRadius = UDim.new(0, 8)
cashCorner.Parent = cashFrame
local cashIcon = Instance.new("TextLabel")
cashIcon.Name = "CashIcon"
cashIcon.Size = UDim2.new(0, 30, 1, 0)
cashIcon.Position = UDim2.new(0, 5, 0, 0)
cashIcon.BackgroundTransparency = 1
cashIcon.Text = "$"
cashIcon.TextColor3 = Color3.fromRGB(255, 215, 0)
cashIcon.TextScaled = true
cashIcon.Font = Enum.Font.GothamBold
cashIcon.Parent = cashFrame
local cashLabel = Instance.new("TextLabel")
cashLabel.Name = "CashLabel"
cashLabel.Size = UDim2.new(1, -40, 1, 0)
cashLabel.Position = UDim2.new(0, 38, 0, 0)
cashLabel.BackgroundTransparency = 1
cashLabel.Text = "0"
cashLabel.TextColor3 = Color3.new(1, 1, 1)
cashLabel.TextScaled = true
cashLabel.Font = Enum.Font.GothamBold
cashLabel.TextXAlignment = Enum.TextXAlignment.Left
cashLabel.Parent = cashFrame
-- Wood Chopped Display
local woodFrame = Instance.new("Frame")
woodFrame.Name = "WoodFrame"
woodFrame.Size = UDim2.new(0, 180, 0, 40)
woodFrame.Position = UDim2.new(0, 220, 0, 5)
woodFrame.BackgroundColor3 = Color3.fromRGB(120, 80, 40)
woodFrame.BackgroundTransparency = 0.3
woodFrame.BorderSizePixel = 0
woodFrame.Parent = topBar
local woodCorner = Instance.new("UICorner")
woodCorner.CornerRadius = UDim.new(0, 8)
woodCorner.Parent = woodFrame
local woodLabel = Instance.new("TextLabel")
woodLabel.Name = "WoodLabel"
woodLabel.Size = UDim2.new(1, -10, 1, 0)
woodLabel.Position = UDim2.new(0, 10, 0, 0)
woodLabel.BackgroundTransparency = 1
woodLabel.Text = "Wood: 0"
woodLabel.TextColor3 = Color3.new(1, 1, 1)
woodLabel.TextScaled = true
woodLabel.Font = Enum.Font.GothamMedium
woodLabel.TextXAlignment = Enum.TextXAlignment.Left
woodLabel.Parent = woodFrame
-- Equipped Tool Display
local toolFrame = Instance.new("Frame")
toolFrame.Name = "ToolFrame"
toolFrame.Size = UDim2.new(0, 180, 0, 40)
toolFrame.Position = UDim2.new(0.5, -90, 0, 5)
toolFrame.AnchorPoint = Vector2.new(0, 0)
toolFrame.BackgroundColor3 = Color3.fromRGB(60, 60, 80)
toolFrame.BackgroundTransparency = 0.3
toolFrame.BorderSizePixel = 0
toolFrame.Parent = topBar
local toolCorner = Instance.new("UICorner")
toolCorner.CornerRadius = UDim.new(0, 8)
toolCorner.Parent = toolFrame
local toolLabel = Instance.new("TextLabel")
toolLabel.Name = "ToolLabel"
toolLabel.Size = UDim2.new(1, -10, 1, 0)
toolLabel.Position = UDim2.new(0, 10, 0, 0)
toolLabel.BackgroundTransparency = 1
toolLabel.Text = "Axe: BasicAxe"
toolLabel.TextColor3 = Color3.new(1, 1, 1)
toolLabel.TextScaled = true
toolLabel.Font = Enum.Font.GothamMedium
toolLabel.TextXAlignment = Enum.TextXAlignment.Center
toolLabel.Parent = toolFrame
-- Weather Display
local weatherFrame = Instance.new("Frame")
weatherFrame.Name = "WeatherFrame"
weatherFrame.Size = UDim2.new(0, 140, 0, 40)
weatherFrame.Position = UDim2.new(1, -150, 0, 5)
weatherFrame.BackgroundColor3 = Color3.fromRGB(50, 70, 100)
weatherFrame.BackgroundTransparency = 0.3
weatherFrame.BorderSizePixel = 0
weatherFrame.Parent = topBar
local weatherCorner = Instance.new("UICorner")
weatherCorner.CornerRadius = UDim.new(0, 8)
weatherCorner.Parent = weatherFrame
local weatherLabel = Instance.new("TextLabel")
weatherLabel.Name = "WeatherLabel"
weatherLabel.Size = UDim2.new(1, -10, 1, 0)
weatherLabel.Position = UDim2.new(0, 5, 0, 0)
weatherLabel.BackgroundTransparency = 1
weatherLabel.Text = "Clear"
weatherLabel.TextColor3 = Color3.new(1, 1, 1)
weatherLabel.TextScaled = true
weatherLabel.Font = Enum.Font.GothamMedium
weatherLabel.TextXAlignment = Enum.TextXAlignment.Center
weatherLabel.Parent = weatherFrame
-- ========== HOTBAR HINTS ==========
local hintsFrame = Instance.new("Frame")
hintsFrame.Name = "ControlHints"
hintsFrame.Size = UDim2.new(0, 400, 0, 30)
hintsFrame.Position = UDim2.new(0.5, -200, 1, -40)
hintsFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
hintsFrame.BackgroundTransparency = 0.5
hintsFrame.BorderSizePixel = 0
hintsFrame.Parent = screenGui
local hintsCorner = Instance.new("UICorner")
hintsCorner.CornerRadius = UDim.new(0, 6)
hintsCorner.Parent = hintsFrame
local hintsLabel = Instance.new("TextLabel")
hintsLabel.Size = UDim2.new(1, -10, 1, 0)
hintsLabel.Position = UDim2.new(0, 5, 0, 0)
hintsLabel.BackgroundTransparency = 1
hintsLabel.Text = "[Click] Punch/Chop [B] Build [C] Craft [I] Inventory [P] Shop [L] Quests [M] Market [O] Settings"
hintsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
hintsLabel.TextScaled = true
hintsLabel.Font = Enum.Font.Gotham
hintsLabel.Parent = hintsFrame
-- ========== UPDATE LOOP ==========
RunService.Heartbeat:Connect(function()
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local cash = leaderstats:FindFirstChild("Cash")
if cash then
cashLabel.Text = Utility.formatCash(cash.Value)
end
local wood = leaderstats:FindFirstChild("WoodChopped")
if wood then
woodLabel.Text = "Wood: " .. tostring(wood.Value)
end
end
-- Update equipped tool display
local axeType = player:GetAttribute("EquippedAxe") or "BasicAxe"
toolLabel.Text = "Axe: " .. axeType
end)