I have no idea how to equip tool and play anim idle and attack anim

wait(1)
local tool = script.Parent

local hum = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
local animload = hum:LoadAnimation(tool.Anim:WaitForChild("DuelGunWeld"))
local animloadidle = hum:LoadAnimation(tool.Anim:WaitForChild("DuelGunIdle"))
local count = 0

local attackanim = {
	tool.Anim.Attack[1],
	tool.Anim.Attack[2],
}

tool.Equipped:Connect(function()
	local char = game:GetService("Players").LocalPlayer.Character
	local hum = char:FindFirstChild("Humanoid")
	local Animate = char:FindFirstChild("Animate")
	
	spawn(function()
		animload:Play()
		animload.Stopped:Wait()
		animloadidle:Play()
	end)
end)

tool.Unequipped:Connect(function()
	local char = game:GetService("Players").LocalPlayer.Character
	local hum = char:FindFirstChild("Humanoid")
	spawn(function()
		animload:Stop()
		animloadidle:Stop()
	end)
end)

tool.Activated:Connect(function()	
	count = count + 1
	print(count)
	
	local attackanim = hum:LoadAnimation(attackanim[count])
	attackanim:Play()
	if count == 2 then
		count = 0
	end
end)

here the code so the anim overlap the walk anim r15 default walk anim that it

I cleaned the code some but try using the animator that way it replicates the animations to all clients

the way your doing the attack animations is abit odd but should work i think

you may want to set these animations priorities to action

wait(1)
local tool = script.Parent

local Player = game.Players.LocalPlayer
local Character = Player.Character

local hum = Character:WaitForChild("Humanoid")
local Animator = hum:WaitForChild('Animator')
local animload = Animator:LoadAnimation(tool.Anim:WaitForChild("DuelGunWeld"))
local animloadidle = Animator:LoadAnimation(tool.Anim:WaitForChild("DuelGunIdle"))
local count = 0

local attackanim = {
	tool.Anim.Attack[1],
	tool.Anim.Attack[2],
}

tool.Equipped:Connect(function()
	local char = Player.Character
	local hum = char:FindFirstChild("Humanoid")
	
	spawn(function()
		animload:Play()
		animload.Stopped:Wait()
		animloadidle:Play()
	end)
end)

tool.Unequipped:Connect(function()
	spawn(function()
		animload:Stop()
		animloadidle:Stop()
	end)
end)

tool.Activated:Connect(function()	
	count += 1
	print(count)

	local attackanim = Animator:LoadAnimation(attackanim[count])
	attackanim:Play()
	if count >= 2 then
		count = 0
	end
end)
1 Like

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