hello,
recently i made a stamina and sprint update for my game and when i tested it with some of my friends, i saw them having the animation played when they where sprinting but after some time i couldn’t see their animation.
how could i fix it?
Is your animation looped?
If so, then you must be referring to the problem occasionally happening, right? And if so, can you show us your code?
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local anim = Humanoid:LoadAnimation(script.Parent.Animation)
local Exterior = Player.PlayerGui:WaitForChild("Stamina").Frame
local bar = Exterior.Bar
local Equipped = false
local NormalWalkSpeed = 16
local NewWalkSpeed = 25
local power = 10
local sprinting = false
local Mouse = Player:GetMouse()
script.Parent.Equipped:Connect(function()
Equipped = true
end)
script.Parent.Unequipped:Connect(function()
Equipped = false
end)
Mouse.Button1Down:Connect(function()
if Equipped == false then return end
anim.Looped = true
anim:Play()
Humanoid.WalkSpeed = NewWalkSpeed
sprinting = true
while power > 0 and sprinting do
power = power - .03
bar:TweenSize(UDim2.new(1.077, 0, power / 10, 0), 'Out', 'Quint', .1, true)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 42, 42), 0.001)
wait()
if power <= 0 then
anim:Stop()
Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end)
Mouse.Button1Up:Connect(function()
if Equipped == false then return end
anim:Stop()
Humanoid.WalkSpeed = NormalWalkSpeed
sprinting = false
while power < 10 and not sprinting do
power = power + .03
bar:TweenSize(UDim2.new(1.077, 0, power / 10, 0), 'Out', 'Quint', .1, true)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 166, 11), 0.001)
wait()
if power <= 0 then
Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end)
this is the local script in the tool
beacuse its a football where u use the tools to shoot pass etc, so i implemented the system on a tool