i have this script that will change the stamina value. So far it works but there are a few bugs
it’ll go in the negatives and such and idk how to fix it. This is my first time making a stamina script from scratch so im having some trouble
heres the script
–Client
UIS.InputBegan:Connect(function(input, chat)
if chat then return end
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) and input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.D then
local isKeyCown = UIS:IsKeyDown(Enum.KeyCode.LeftShift)
startup = event:InvokeServer({"Running", isKeyCown})
local tween = TS:Create(camera, TweenInfo.new(.5), {FieldOfView = 90})
tween:Play()
end
end)
UIS.InputEnded:Connect(function(input, chat)
if chat then return end
if input.KeyCode == Enum.KeyCode.LeftShift and not UIS:IsKeyDown(Enum.KeyCode.LeftShift) then
if startup == true then
local runEnded = event:InvokeServer({"Not Running"})
if runEnded == true then
local tween = TS:Create(camera, TweenInfo.new(.5), {FieldOfView = 70})
tween:Play()
print(1)
end
end
end
end)
–Server
event.OnServerInvoke = function(plr, args)
if plr then
local char = plr.Character
local hum = char.Humanoid
local stamValue = plr.Backpack.MovementValues.StaminaValue
----
if args[1] == "Running" then
print("player is running")
while args[2] do
stamValue.Value -= 1
if stamValue.Value == 1 then
return true
end
task.wait()
end
return true
elseif args[1] == "Not Running" then
print("player is not running")
while not args[2] do
stamValue.Value += 1
if stamValue.Value == 99 then
return true
end
if stamValue.Value == 100 then
break
end
task.wait()
end
return true
end
end
end
the script isnt finished yet and it cropped out the parts that are not relevant to the topic
help and feedback is greatly appriciated. Thank you for your time!