when im testing in studio at a consistent 60 fps it gets the results i want but when i test in the roblox client because i get more frames the stamina goes down quicker. is there any way i can fix it so it always runs at a consistent 60 fps/hz no matter what the clients framerate is
this is a part of the whole script
runservice.RenderStepped:Connect(function(delta)
local stamina = plrstats:FindFirstChild('Stamina')
if stamina.Value < staminausage.Value then
isSprinting = false
hum.WalkSpeed = plrstats:FindFirstChild("BaseWalkSpeed").Value
sprintanim:Stop()
tweenservice:Create(camera, tweeninfo, {FieldOfView = 70}):Play()
rechargeTime.Value = 3
end
if stamina.Value > 100 then
stamina.Value = 100
elseif stamina.Value < 0 then
stamina.Value = 0
end
if isCrouching then
if hum.MoveDirection.Magnitude > 0 then
if not crouchmoveanim.IsPlaying then
crouchmoveanim:Play()
crouchanim:Stop()
end
else
if not crouchanim.IsPlaying then
crouchanim:Play()
crouchmoveanim:Stop()
end
end
end
if isSprinting and stamina.Value > 0 and hum.MoveDirection.Magnitude > 0 and hum.WalkSpeed > 0 then
stamina.Value -= staminausage.Value
lastsprint = tick()
else
if tick() - lastsprint >= rechargeTime.Value and stamina.Value < plrstats:FindFirstChild('MaxStamina').Value then
stamina.Value += staminaregen.Value
rechargeTime.Value = 1
end
end
staminaGUI.StaminaBar.Bar.Size = UDim2.new(1 - (1 - (stamina.Value/plrstats:FindFirstChild('MaxStamina').Value)), 0, 1, 0)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.