A quick Stamina System for every player

So out of boredom I decided to make a quick stamina script for roblox on discord but I’m not sure if it works. but it should work no problem, if there’s any problem with it do let me know and I’ll try to fix it, there’s also a script for a stamina bar inside it


--ServerScriptService PlayerData1

game.Player.PlayerAdded:Connect(function(Player)

local fold = Instance.new('Folder')
      fold.Name = 'PlayerData1'
      fold.Parent = Player

local Stamina = Instance.new('IntValue')
      Stamina.Name = 'Stamina'
      Stamina.Value = 100
      Stamina.Parent = fold

local CurStamina = Instance.new('IntValue')
      CurStamina.Name = 'CurrentStamina'
      CurStamina.Value = 100
      CurStamina.Parent = Stamina

CurStamina.Changed:Connect(function(NewStam)
if NewStam < Stamina.Value then
        CurStamina.Value += 1
         wait(1)
        end
    end)
end)

--Stamina Bar Local Script

local Player = game.Players.LocalPlayer

Player.PlayerData1.Stamina.CurrentStamina.Changed:Connect(function(NewStam)
     script.Parent.Size = Udin3.new(NewStam/Player.PlayerData1.Stamina.Value,0,1,0)
      script.Parent.Parent.TextLabel.Text = NewStam .. ' / ' .. Player.PlayerData1.Stamina.Value
end)
4 Likes

Please give more set-up information and review/test your code before posting. Currently it would not function as intended, and the burden would be on the person reading this to fix it and make it functional (which may or may not be possible given their level of programming experience.)

Same applies to the stamina bar. The way it is coded relies on a particular and specific way of setting up the GUI (local script as a child of the bar, a text label that is two parents removed from the local script, etc. That’s not intuitive for everyone, nor is there enough detail for less experienced programmers or non-programmers who are seeking to use this resources to get it functioning properly.

1 Like