Basically my tool is a wand. Whenever wand is held, animations are played through this script.
--Idle--
local player = game.Players.LocalPlayer
local equipped = false
repeat wait(1) until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.Name = "Idle"
animation.Parent = script.Parent
local animation2 = Instance.new("Animation")
animation2.Name = "Moving"
animation2.Parent = script.Parent
animation.AnimationId = "http://www.roblox.com/asset/?id=" .. "6096006842"-- id
animation2.AnimationId = "http://www.roblox.com/asset/?id=" .. "6123318013"-- id
local animtrack = humanoid:LoadAnimation(animation)
local movinganimtrack = humanoid:LoadAnimation(animation2)
script.Parent.Equipped:Connect(function()
equipped = true
end)
script.Parent.Unequipped:Connect(function()
equipped = true
end)
while true do
wait()
while equipped == true do
wait()
if game.Players.LocalPlayer.Character.UpperTorso.Velocity == 0 then
movinganimtrack:Stop()
animtrack:Play()
else
animtrack:Stop()
movinganimtrack:Play()
end
end
end
When the wand is equipped, if you're not moving, then the first animation (animtrack) plays. If you are moving while the wand is equipped, then the second animation (movinganimtrack) plays. However, I'm getting multiple bugs. Currently the bug I'm getting is it'll set off randomly when I'm holding the wand even if I don't move. On the other hand, when I use the humanoid.Running function, it works but when I unequip the wand it doesn't stop the animation and it breaks. Any help please? Thanks.
