#My sprint animation is bugging

1 messages · Page 1 of 1 (latest)

wispy torrent
#

I try to play my animation to see what it looks like but it's not like the rig, with the same animID, i don't know where the problem is...(I'm french sorry for my english)

uncut coral
#

give the script here

#

@wispy torrent

wispy torrent
# uncut coral <@665254612739162163>

local UserInputService = game:GetService("UserInputService")
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
local camera = game.Workspace.Camera
local animation = script.runAnimation
local AnimTrack = humanoid:LoadAnimation(animation)

local sprint = false
local walkSpeed = 10
local sprintSpeed = 25

local maxStamina = 1000
local stamina = maxStamina
local regenStamina = maxStamina/600
local drainSpeed = 0.25
local drained = false

local function isMoving()
local moveDirection = humanoid.MoveDirection
return moveDirection.Magnitude > 0
end

RunService.Heartbeat:Connect(function()
if sprint then
if stamina > 0 then
stamina = math.max(stamina - drainSpeed, 0)
AnimTrack:Play()
else
sprint = false
drained = true
humanoid.WalkSpeed = walkSpeed
camera.FieldOfView = 60
end
elseif not sprint then
stamina = math.min(stamina + regenStamina, maxStamina)
if drained and stamina == maxStamina then
drained = false
end
if not isMoving() then
camera.FieldOfView = 60
end
end
end)

UserInputService.InputBegan:Connect(function(Input, isTyping)
if isTyping then return end
if Input.KeyCode == Enum.KeyCode.LeftShift and not drained and isMoving() then
sprint = true
camera.FieldOfView = 55
humanoid.WalkSpeed = sprintSpeed
end
end)

UserInputService.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
sprint = false
camera.FieldOfView = 60
humanoid.WalkSpeed = walkSpeed
end
end)

#

i've juste put a :Pley() one time to see the loop of the animation

#

but the loop didn't worl

uncut coral
#

:Pley()?

wispy torrent
uncut coral
#

ur calling the animation every frame

#

only play it when sprinting is true and then stop it if sprinting ends

wispy torrent
#

i try it but the result is the same

random minnowBOT
#

studio** You are now Level 1! **studio

uncut coral
wispy torrent
#

with your option

wispy torrent
uncut coral
#

is ur anim Looped?

wispy torrent
uncut coral
#

ur anim is restarting every frame in heartbeat service

#

remove AnimTrack:Play() from heartbeat and

#

move it to inputbegan

wispy torrent
#

yeah i've do that, there is no more AnimTrack:Play() form heartbeat but the problem is still the same

uncut coral
#

add this to the heartbeat

#

wait

#

ill type it

wispy torrent
#

thx

uncut coral
#

if AnimTrack:IsPlaying then
AnimTrack:Stop()

#

at the end

#

and check animation properties

#

if looped is enabled

wispy torrent
#

RunService.Heartbeat:Connect(function()
if sprint then
if stamina > 0 then
stamina = math.max(stamina - drainSpeed, 0)
else
sprint = false
drained = true
humanoid.WalkSpeed = walkSpeed
camera.FieldOfView = 60
end
elseif not sprint then
stamina = math.min(stamina + regenStamina, maxStamina)
if drained and stamina == maxStamina then
drained = false
end
if not isMoving() then
camera.FieldOfView = 60
end
end
AnimTrack:Stop()
end)

#

like that ?

uncut coral
#

no

uncut coral
#

under camera.FieldofView

wispy torrent
#

ohhh

#

thx ill try

wispy torrent
uncut coral
#

also have u checked ur animation properties

#

does it have looped

wispy torrent
uncut coral
#

enabled

#

find ur animation

#

that u use

#

or u use

#

roblox one

#

check the run animation properties

#

in workspace

wispy torrent
#

my roblox studio is very laggy...

#

i will try

wispy torrent
random minnowBOT
#

studio** You are now Level 2! **studio

uncut coral
#

u got any errors in output?

#

in ur original script

#

that u gave

wispy torrent
#

no i don't

wispy torrent
uncut coral
#

give ur animid

#

imma test sum

#

this thing

wispy torrent
#

loop is actived

uncut coral
#

give ur animid

wispy torrent
#

86305053668673

uncut coral
#

u got any errors in ur output?

wispy torrent
#

i've checked and no i don't

#

that very weird

uncut coral
#

idk im clueless tbh

#

wait

wispy torrent
#

is the problem from here ?

uncut coral
#

okay wait

#

i got the animation and the script in my studio

#

imma try some things rq

#

i got the same error u hav

wispy torrent
#

if i remove the runservice that doesn't work aswell

uncut coral
#

so what i think

#

myself

#

if im wrong or not

#

but

#

walk overrides the animation

#

imma fix it rq

#

and then send u the script

wispy torrent
#

Thx

#

I have to delete the walk animation of the rig that i use in statercharacter ?

uncut coral
#

nono

#

dont delete anything

#

its simple fix

#

just setting the priority higher in script

#

give me 1 sec

wispy torrent
#

okay thx

uncut coral
#

ill send the new script in dms

#

with fixing the heartbeat etc

wispy torrent