Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to make animations loop smoothly with a click detector?

Asked by 4 years ago
Edited 4 years ago

(I am new to lua and coding in general so if there is a simple solution that everyone knows than sorry :/ ) So I'm working on a game where I want the player to have animations when they click on an object. In other words I need a typing animation to play when the player clicks on a computer. Here is the script I am using currently:

local Animation = script.Parent.Animation

script.Parent.MouseClick:connect(function(player)

    player.Value.Value = player.Value.Value + .1

 local AnimationTrack = player.Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
   AnimationTrack:Play()
end) 

the problem with this is that it isn't very smooth and it looks bad when you click really fast. also here is the animation if anybody wants to see it (its not very good)

https://www.roblox.com/library/5580976281/typing

1 answer

Log in to vote
0
Answered by
HEMAN_9 70
4 years ago

I believe the problem your having is that the animation keeps starting over after you click the first time. To fix this, you can use a technique called debounce to make sure that you can only do the animation once in a certain amount of time. Theres a video here about how to use them. (https://www.youtube.com/watch?v=HoZkuvd6RPA) If however the problem is that when played the animation does not look fluent when looped then one way to fix that is to make sure the beginning and ending key frames of your animation are the same.

0
Turns out I was having both problems XD. Thanks TheyCallMeLaggy 2 — 4y
Ad

Answer this question