recently i encountered a bug in my game while i was working on my stamina gui
everytime the stamina ui reaches a certain y offset it just disappears for now reason
robloxapp-20240701-1812137.wmv (1.0 MB)
(sorry for low quality)
i dont think it has anything to do with the script but here is it anyway
local player = game:GetService("Players").LocalPlayer
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local activetool = false
local A = require(game:GetService("ReplicatedStorage").Assets.Module.Assets)
----------------------------------------
local uis = game:GetService("UserInputService")
local cas = game:GetService("ContextActionService")
local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")
-------------
local Stamina = 100
local StaminaCap = Stamina
local DrainStamina = .05
local IsRunning
local Rspeed = 25
local Nspeed = 16
local IsWalking
local RFOV = 73
local NFOV = 70
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local Info2 = TweenInfo.new(.7, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local FOVchange = ts:Create(game.Workspace.CurrentCamera,Info,{FieldOfView = RFOV})
local FOVdef = ts:Create(game.Workspace.CurrentCamera,Info,{FieldOfView = NFOV})
local rt = ts:Create(humanoid,Info2,{WalkSpeed = Rspeed})
local wt = ts:Create(humanoid,Info2,{WalkSpeed = Nspeed})
local lastTime = tick()
local maxTick = 1
-------------
local anim = game:GetService("ReplicatedStorage").Assets.Animations.Run
local runanim = humanoid:LoadAnimation(anim)
-------------
local Torso = game.Players.LocalPlayer.Character:WaitForChild("Torso")
local StaminaUI = A.StaminaUI:Clone();StaminaUI.Parent = Torso
local Holder = StaminaUI.Holder
local Bar = Holder.Bar
-------------
A.ToolActive.OnClientEvent:Connect(function()
if activetool == false then
activetool = true
wait(1)
activetool = false
end
end)
humanoid.AutoRotate = true
local function StopRun()
runanim:Stop()
IsRunning = false
wt:Play()
FOVdef:Play()
end
local function PlayRun()
runanim:Play()
IsRunning = true
rt:Play()
FOVchange:Play()
end
rs.Heartbeat:Connect(function()
Bar.Size = UDim2.new(0,23,0,Stamina*2.51)
if IsRunning == true then
Stamina = Stamina - DrainStamina
elseif IsRunning == false and Stamina < StaminaCap then
Stamina = Stamina + DrainStamina
end
if Stamina <= 0 then
StopRun()
end
end)
humanoid.Running:connect(function(Speed)
if Speed == Rspeed and IsRunning and not runanim.IsPlaying then
PlayRun()
elseif Speed == Rspeed and not IsRunning and runanim.IsPlaying or Speed == Nspeed and runanim.IsPlaying or Stamina == 0 or workspace.CurrentCamera.FieldOfView > NFOV and not IsRunning then
StopRun()
elseif Speed == Rspeed and runanim.IsPlaying and activetool == true or runanim.IsPlaying and activetool == true then
StopRun()
end
end)
humanoid.Changed:Connect(function()
if runanim.IsPlaying and humanoid.Jump then
StopRun()
end
end)
uis.InputBegan:Connect(function(input, gameprocessed)
if not gameprocessed then
if input.KeyCode == Enum.KeyCode.W and not activetool then
if tick() - lastTime <= 1 then
PlayRun()
else
lastTime = tick()
end
end
end
end)
uis.InputEnded:Connect(function(input, gameprocessed)
if not gameprocessed then
if IsRunning and input.KeyCode == Enum.KeyCode.W then
StopRun()
end
end
end)
(line 63 - 73)