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

Starting an animation from the start?

Asked by 4 years ago

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

Log in to vote
0
Answered by
sheepposu 561 Moderation Voter
4 years ago
Edited 4 years ago

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)
Ad

Answer this question