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

Starting an animation from the start?

This is a tool when equipped it plays a animation, i want it to go back to the start of the animation without it going fast. Is there any fix for this?

AnimationId = "248263260"
   local Anim = Instance.new("Animation")
   Anim.AnimationId = "rbxassetid://"..AnimationId
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://"..AnimationId
local k = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Anim)
k.Looped = true
k.Priority = "Action"

local Tool = Instance.new("Tool", game.Players.LocalPlayer.Backpack)
Tool.Name = "Idle"
Tool.RequiresHandle = false
Tool.CanBeDropped = false


function Equip()
while true do
wait()
  k:Play(99)
		k:AdjustSpeed(2)
		wait(2)
		 k:Stop(99)
		k:AdjustSpeed(2)
		wait(1)
		k:Play(99)
		k:AdjustSpeed(2)
end
end

function UnEquip()
  k:Stop(99)
		k:AdjustSpeed(2)
end

Tool.Equipped:Connect(Equip)
Tool.Unequipped:Connect(UnEquip)

 

1 answer

I think what you want to do is continuously play the animation, just play by itself with put it on loop, then stop it when the tool is unequipped.

AnimationId = "248263260"
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://"..AnimationId
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://"..AnimationId
local k = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Anim)
k.Looped = true
k.Priority = "Action"

local Tool = Instance.new("Tool", game.Players.LocalPlayer.Backpack)
Tool.Name = "Idle"
Tool.RequiresHandle = false
Tool.CanBeDropped = false


function Equip()
    k:Play()
end

function UnEquip()
    k:Stop()
end

Tool.Equipped:Connect(Equip)
Tool.Unequipped:Connect(UnEquip)

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