Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't my animation slow down after using AdjustSpeed()?

I'm working on a shooter game that requires the player to reload after they use up all their bullets in a clip. Each gun takes different length of times to reload, so I need to change the animation length to fit the reload time. I've currently tried the AdjustSpeed() method to change the speed to play at 75% of it's original speed (which, I've tested, prints out 0.75 as its speed), but when the animation track is played using :Play(), the animation does not appear to be slowing down.

Here is the function for reloading:

function reload()
	reloading = true
	reloadAnim:AdjustSpeed(reloadAnim.Length/reloadTime.Value) -- Anim speed does change, but it doesn't appear to slow down when played??
	print(reloadAnim.Speed) -- Prints out 0.75
	reloadAnim:Play() -- Animation finishes playing a noticeable amount quicker than the wait() time, despite having its speed changed to 0.75
	wait(reloadTime.Value) 
	clips.Value = clips.Value - 1 -- Clip and ammo values changes a while after the animation has finished playing
	ammo.Value = maxAmmo.Value
	reloading = false
end

reloadAnim is an already-loaded AnimationTrack that has an original length of 1.5 seconds, and the reloadTime.Value is 2. The reload function is called with reload() once when the player presses the "R" key.

If there is not enough context to solve this issue, please let me know.

2 comments

0

Could you possibly post the other code. Like when they press the R key

0

"reload()" is the only code that will run when the key "R" is pressed, I used UserInputService to listen for the input.

1 answer

function reload()
    reloading = true
    
    print(reloadAnim.Speed) -- Prints out 0.75
    reloadAnim:Play() -- Animation finishes playing a noticeable amount quicker than the wait() time, despite having its speed changed to 0.75
	reloadAnim:AdjustSpeed(reloadAnim.Length/reloadTime.Value) -- Anim speed does change, but it doesn't appear to slow down when played??
    wait(reloadTime.Value) 
    clips.Value = clips.Value - 1 -- Clip and ammo values changes a while after the animation has finished playing
    ammo.Value = maxAmmo.Value
    reloading = false
end

This discussion is preserved as it was. New answers, comments, and votes are closed.