#Stamina starts tripping after exhausted is over
15 messages · Page 1 of 1 (latest)
i dont think i defined it as anything
no sorry dt is for delatime so its staminaDrain/stamineRecharge * deltatime
** You are now Level 1! **
drain works fine
its just as soon as i stop sprinting it spasses out for some time and then starts regenerating normally
and at 0 stamina it doesnt regenerate at all it just gets stuck on the output i showed
can you just print out this: print(staminaRecharge * dt)
right above this line
Humanoid:SetAttribute("Stamina", stamina + (staminaRecharge * dt))
i wanna see what that outputs the value that gets added to stamina
i see your error i think
UIS.InputBegan:Connect(function(input)
if input.KeyCode ~= Enum.KeyCode.LeftShift then return end
isSprinting = true
sprint(isSprinting)
end)
in this part stop the user from accessing sprint otherwise it can happen that for example:
your stamina is 0.15 which is greater than 0 so you allow the player to sprint BUT this part:
if isSprinting and stamina > 0 and Humanoid.MoveDirection.Magnitude > 0 then
Humanoid:SetAttribute("Stamina", stamina - (staminaDrain * dt))
may be deducting 0.47 since drain is higher than regenerating
so in this case you end up negative which should explain the negative number
so a simple check (if you still hold down shift) should do the trick
so maybe check that:
UIS.InputBegan:Connect(function(input)
if input.KeyCode ~= Enum.KeyCode.LeftShift then return end
if (stamina - (staminaDrain * dt)) >= Humanoid:GetAttribute("Stamina") then return end
isSprinting = true
sprint(isSprinting)
end)
something like this should do the trick @whole herald
anyway for me to get dt into the UIS function? it now just tells me dt is not a global