I know that Stamina shouldnt be nil but it always gives this error:
18:54:57.446 - Players.Player.Backpack.StaminaRegen:14: attempt to index local 'Stamina' (a nil value)
local Player = game.Players.LocalPlayer
Player.CharacterAdded:connect(function ()
Player = game.Players.LocalPlayer
local Stamina = Player.Character:FindFirstChild("StaminaValue")
local MaxStamina = Player.Character:FindFirstChild("MaxStaminaValue")
while wait() do
if Stamina.Value < MaxStamina.Value then
Stamina.Value = Stamina.Value + 1
wait(0.01)
end
end
end)
Please help.

2 comments
Player.Character:findFirstChild("StaminaValue") is returning nil, are you sure there is a value called that in the Character...? Nothing in this code has created it...
@DevSean It was created in another code