Attempt to index number with 'Value'

The Stamina, Maxstamina is a number Value object, i tried printing outthe stamina.value and its a number but the "attempt to index number with ‘Value’ " error showed up.
Script:

local char = script.Parent
local PlayerStats = char:WaitForChild("PlayerStats")
local Stamina = PlayerStats:WaitForChild("Stamina")
local MaxStamina = PlayerStats:WaitForChild("MaxStamina")
local allowStaminaRegen = PlayerStats:WaitForChild("allowStaminaRegen")

local REGEN_RATE = 5/100
local REGEN_STEP = 0.1

while allowStaminaRegen.Value == true do
	print(Stamina.Value)
	while Stamina.Value < MaxStamina.Value do -- attempt to index number with 'Value' 
		local dt = wait(REGEN_STEP)
		local dh = dt*REGEN_RATE*MaxStamina.Value
		Stamina = math.min(Stamina.Value + dh, MaxStamina.Value)
	end
	Stamina:GetPropertyChangedSignal("Value"):Wait()
end
1 Like

A couple lines below, you assigned “Stamina” to a number. Replace:

		Stamina = math.min(Stamina.Value + dh, MaxStamina.Value)

with

		Stamina.Value = math.min(Stamina.Value + dh, MaxStamina.Value)
2 Likes

ah yes. I’ll try to look thru the script more carefully next time