studs counter
Key RequiredUniversal

studs counter

Universal Scripthiffhiff 16.8K views 33 executesUpdated Aug 10, 2023
5.0/ 5(2 votes)
20100% Positive
Lua Script•93 lines (2808 chars)
local player = game:GetService("Players").LocalPlayer --counts your studs, counter resets when you respawn.

local function createStudsWalkedGUI()
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

    local totalStudsWalked = 0
    local isCharacterAlive = true

    
    local gui = Instance.new("ScreenGui")
    gui.Name = "StudsWalkedGUI"
    gui.ResetOnSpawn = false
    gui.Parent = player.PlayerGui

    local frame = Instance.new("Frame")
    frame.Size = UDim2.new(0, 200, 0, 50)
    frame.Position = UDim2.new(0.5, -100, 0.9, -50)
    frame.BackgroundTransparency = 0.5
    frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
    frame.Active = true -- Enable GUI interaction
    frame.Draggable = true -- Allow the GUI to be dragged
    frame.Parent = gui

    local label = Instance.new("TextLabel")
    label.Size = UDim2.new(1, 0, 1, 0)
    label.BackgroundTransparency = 1
    label.Text = "Studs Walked: 0"
    label.TextColor3 = Color3.fromRGB(255, 255, 255)
    label.TextScaled = true
    label.Parent = frame


    local function formatStuds(studs)
        local formattedStuds = tostring(math.floor(studs))
        local reverseFormatted = string.reverse(formattedStuds)
        local withCommas = string.gsub(reverseFormatted, "(%d%d%d)", "%1,")
        return string.reverse(withCommas:gsub("^,", ""))
    end

    
    local function updateStudsWalked(deltaTime)
        if isCharacterAlive then
            local movementVector = humanoidRootPart.Velocity * deltaTime
            local studsWalked = movementVector.Magnitude
            totalStudsWalked = totalStudsWalked + studsWalked
            label.Text = "Studs Walked: " .. formatStuds(totalStudsWalked)
        end
    end

    
    local function onCharacterDeath()
        isCharacterAlive = false
    end

    
    local function onCharacterAdded(newCharacter)
        for _, child in ipairs(gui:GetChildren()) do
            child:Destroy()
        end

        character = newCharacter
        humanoidRootPart = character:WaitForChild("HumanoidRootPart")
        totalStudsWalked = 0
        isCharacterAlive = true
        label.Text = "Studs Walked: 0"
    end

    
    character:WaitForChild("Humanoid").Died:Connect(onCharacterDeath)
    player.CharacterAdded:Connect(onCharacterAdded)

    
    local function update(deltaTime)
        if isCharacterAlive then
            updateStudsWalked(deltaTime)
        end
    end

    game:GetService("RunService").Heartbeat:Connect(update)
end


createStudsWalkedGUI()


player.CharacterAdded:Connect(function()
    local previousGUI = player.PlayerGui:FindFirstChild("StudsWalkedGUI")
    if previousGUI then
        previousGUI:Destroy()
    end
    createStudsWalkedGUI()
end)

Features & Information

counts your studs, counter resets when you respawn. (doesnt count accurately in r15) NOTE: This is a reupload due to the data rollback, you may have already seen this.
#studs#auto#counter#walk#op

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts