Example 1:
Run from a (Server) Script
local player = game.Players.LocalPlayer
local animation = Instance.new("Animation", script)
local check = Instance.new("BoolValue", script)
animation.AnimationId = "rbxassetid://0"
workspace:WaitForChild("player.Name")
local loadedAnimation = player.Character.Humanoid:LoadAnimation(animation)
while true do
if check.Value == false then
loadedAnimation:Play()
wait(2)
else
wait()
end
end
Notes
Line 3: Set this to the id number of the animation (you MUST own it)
Line 12: The number in the wait(#) should be the amount of time the animation runs for (default of 2)
Explanation: your "kame" acts as a debounce, but by using the repeat until event, you are unable to replay the loop after kame is changed. (although in your script, it never does?) You also never set the animation id number, so you'll need to add that to the script. Setting the BoolValue added above to true will cause the animation to stop, and you could also restart it later.
Example 2:
Run from a (Server) Script
local player = game.Players.LocalPlayer
local animation = Instance.new("Animation", script)
animation.AnimationId = "rbxassetid://0"
workspace:WaitForChild("player.Name")
local loadedAnimation = player.Character.Humanoid:LoadAnimation(animation)
loadedAnimation.Looped = true
repeat
loadedAnimation:Play()
wait(2)
until loadedAnimation.Looped = false
Notes: Same As Above
Explanation: The looped property of the animationtrack will allow you to play the animation continuously. All you have to do is make a function set the looped property to false and the animation will end.
1 comment
.Loopedproperty