So I made this punching tool (Followed a tutorial)
and I made the idle animation for my punch tool, but when I walk it stops when I locked: right leg, left leg, and torso when making the animation. Here's the server and local script.
server
local tool = script.Parent
local hitsound = tool:WaitForChild("Hit")
local canattack = tool:WaitForChild("CanAttack")
local plr = tool.Parent.Parent
local char = plr.Character or plr.CharacterAdded:wait()
local larm = char:WaitForChild("Left Arm") -- this can be changed im only using this for the R6 body type
local rarm = char:WaitForChild("Right Arm") -- this can be changed im only using this for the R6 body type
larm.Touched:connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if canattack.Value == false then
if hum then
canattack.Value = true
hitsound:Play()
hum:TakeDamage(5) -- u can change this value
wait(.5)
canattack.Value = false
end
end
end)
rarm.Touched:connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if canattack.Value == false then
if hum then
canattack.Value = true
hitsound:Play()
hum:TakeDamage(5) -- u can change this value
wait(.5)
canattack.Value = false
end
end
end)
Client/Local
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local tool = script.Parent
local swingsound = tool:WaitForChild("Swing")
local canattack = tool:WaitForChild("CanAttack")
tool.Equipped:connect(function()
local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
idle:Play()
end)
tool.Activated:connect(function()
local choose = math.random(1,2)
canattack.Value = true
if choose == 1 then
local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1)
swingsound:Play()
swing1animation:Play()
elseif choose == 2 then
local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2)
swingsound:Play()
swing2animation:Play()
end
end)
tool.Deactivated:connect(function()
canattack.Value = true
end)
tool.Unequipped:connect(function()
local hum = char:WaitForChild("Humanoid")
for _,anim in pairs(hum:GetPlayingAnimationTracks()) do
anim:Stop()
end
end)
I put 3 of the animations inside the local script and I put a bool value in the tool named "CanAttack" just like the tutorial. I don't know why the guy who made the tutorial didn't have the idle animation problem like me, please tell me whats wrong.
