How do I "Unloop" an animation?

How do I “Unloop” an animation?

alright this may sound weird, but I’m having trouble with my scripts, I want the animation
to stop playing after 0.4 seconds, however I have no clue how to do this, I’ve tried to set it’s value to false, but it doesn’t work. I searched it up, but didn’t find any helpful answer.

local remote = game.ReplicatedStorage.RemoteEvent
local tween = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local tweeninfo2 = TweenInfo.new(0.4, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)

remote.OnServerEvent:Connect(function(player, Pos)
	local Kunai = game.ReplicatedStorage.Kunai:Clone()
	Kunai.Parent = game.Workspace
	local char = game.Workspace:FindFirstChild(player.Name)
	local leftarm = char["Left Arm"]
	local beam = leftarm.Att01.Beam
	local Att01 = leftarm.Att01
	beam.Attachment0 = Att01
	beam.Attachment1 = Kunai.Attachment
	local hum = char:FindFirstChild("Humanoid", true)
	local anim = hum:LoadAnimation(script.Animation)
	anim:Play()
	local number = 0
	while number <= 0.15 do
		Kunai.Position = Att01.WorldPosition
		Kunai.Orientation = Att01.WorldOrientation
		wait(.01)
		number = number + 0.01
	end
	local goal = {Position = Pos}
	local tweenp = tween:Create(Kunai, tweeninfo, goal)
	tweenp:Play()
	wait(0.1)
	local hrp = char:FindFirstChild("HumanoidRootPart", true)
	local animpl = hum:LoadAnimation(script.Animation2)
	animpl:Play()
	animpl.Looped = true
	local tweenp2 = tween:Create(hrp, tweeninfo2, goal)
	tweenp2:Play()
	wait(0.4)
	animpl.Looped = false
end)

Specifically this part

	animpl.Looped = true
	local tweenp2 = tween:Create(hrp, tweeninfo2, goal)
	tweenp2:Play()
	wait(0.4)
	animpl.Looped = false

I’m stuck with the animation, if you could help me “Unloop” it, so stop playing the animation I’d be happy, thank you for reading.

3 Likes

Roblox just does that. You can make a default not looped anim loop, but you can’t make a default looped anim not loop, if any of that makes sense. Open your animation in your animator and manually set looped to false, then just reapply it and change nothing about your script.

2 Likes

Why disable the loop? Just stop the animation?

1 Like

What you could do is making a KeyFrame in your animation. It’s a form of “Marking”/“Pinning” you can enable at certain points in your animation, and then stop the animation when it have reached that point. This can be done when you’re animating your animation.

1 Like

How do I do that, I usually don’t use these kind of scripts

1 Like

:LoadAnimation() returns an AnimationTrack, they have a Looped property aswell as a :Stop() method.

1 Like

You tick of “looping” when you create the animation, it’s all within the animation editor. It’s also where you set stuff like the animationPriority.
image

1 Like

Simply use Animation:Stop() (ignore this sentence i need to meet the char minimum)

1 Like

Yes. I’m wondering if this is a bug too, as the using .looped in a script doesn’t work unless loop is unchecked in the editor. Should I report this or is this intended?

1 Like

Thank you all, I didn’t even know stop was a thing lol, that’s basically what I wanted.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.