this is my stamina script. it does somehow work but numbervalue doesnt change so i had to script whole thing in one script (i want to make a dash part a separate script and make stamina gui based on numbervalue). "stamina" variable is a numbervalue. also its localscript if that matters.
local player = game.Players.LocalPlayer local character = player.Character local humanoid = player.Character:WaitForChild("Humanoid") repeat wait() until player.Character local UIS = game:GetService("UserInputService") WalkingSpeed = 16 RunningSpeed = 32 JumpingPower = 50 stamina = script.Parent.Stamina.Value local isRunning = false local isJumping = false local canRun = true local canDash = true local gui = game.StarterGui.Movement local text = gui.InfoGui.StaminaText staminaDrain = 0.05 staminaRegeneration = 0.1 local tapped = false local dashCooldown = false humanoid.WalkSpeed = WalkingSpeed humanoid.JumpPower = JumpingPower UIS.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift and humanoid and not isRunning and canRun then isRunning = true humanoid.WalkSpeed = RunningSpeed while isRunning and stamina > 0 do text.Text = stamina stamina = stamina - 1 wait(staminaDrain) end if humanoid then humanoid.WalkSpeed = 16 end isRunning = false end end) UIS.InputEnded:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift and humanoid then isRunning = false end end) UIS.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift and humanoid and canDash and not dashCooldown then if tapped == false then tapped = true wait (0.25) tapped = false else dashCooldown = true character.HumanoidRootPart.Velocity = character.HumanoidRootPart.CFrame.lookVector * (stamina + 100) stamina = stamina - 25 wait(3) dashCooldown = false end end end) humanoid.StateChanged:Connect(function(oldState, newState) if newState == Enum.HumanoidStateType.Jumping then stamina = stamina - 10 end end) while true do if not isRunning and stamina < 100 then stamina = stamina + 1 text.Text = stamina end if stamina >= 25 then canRun = true canDash = true humanoid.JumpPower = JumpingPower elseif stamina <= 10 then canRun = false canDash = false isRunning = false humanoid.JumpPower = 0 end if stamina >= 10 then end wait(staminaRegeneration) end
thanks in advance
fixed it. just changed
stamina = script.Parent.Stamina.Value
to
stamina = script.Parent.Stamina
thanks for "help"