So I created a value called “Stamina” (an integer value) in every Player. It is there, I have checked. That part works. The weird part is where it says Stamina.Value = Stamina.Value - 0.2:
local MaxStamina = 500
local StaminaRegen = 2
local SprintStaminaCost = 0.2
local SprintingPlayers = {}
RunService.Heartbeat:Connect(function()
for Index, Player in pairs(game.Players:GetChildren()) do
local Stamina = Player.Stamina
local Name = Player.Name
if not SprintingPlayers[Player.Name] then
if Stamina.Value > MaxStamina then
Stamina.Value = MaxStamina
elseif Stamina.Value < MaxStamina then
Stamina.Value = Stamina.Value + StaminaRegen
end
else
if Stamina.Value >= 0.2 then
print("Sprinting. Stamina: "..Stamina.Value.." Player: "..Player.Name)
Stamina.Value = tonumber(Stamina.Value) - 0.2
else
Player.Character.Humanoid.WalkSpeed = SprintingPlayers[Name]
end
end
end
end)
The value is not depreciating, it remains at 500 instead of 499.98. Here is an output screenshot:
This is a very strange issue, anyone got a fix?