Hello, Im trying to make a gun run system with anims. But for some reason the anim doesnt stop.
Any suggestions on how to fix it?
local function GunRun(PlayOrStop)
for i, v in pairs(Character:GetChildren()) do
if v:IsA("Tool") then
local animation1 --= Humanoid:LoadAnimation(v:FindFirstChild("AnimsFolder").Run)
local animation2 --= Humanoid:LoadAnimation(v:FindFirstChild("Animations").Run)
if v:FindFirstChild("Animations") then
animation2 = Humanoid:LoadAnimation(v:FindFirstChild("Animations").Run)
end
if v:FindFirstChild("AnimsFolder") then
animation1 = Humanoid:LoadAnimation(v:FindFirstChild("AnimsFolder").Run)
end
if PlayOrStop == "Play" then
if v:FindFirstChild("AnimsFolder") then --or v:FindFirstChild("Animations") then
if v:FindFirstChild("AnimsFolder").Run then
animation1:Play()
end
elseif v:FindFirstChild("Animations") then
if v:FindFirstChild("Animations").Run then
animation2:Play()
end
end
elseif PlayOrStop == "Stop" then
if v:FindFirstChild("AnimsFolder") then --or v:FindFirstChild("Animations") then
if v:FindFirstChild("AnimsFolder").Run then
animation1:Stop()
end
elseif v:FindFirstChild("Animations") then
if v:FindFirstChild("Animations").Run then
animation2:Stop()
end
end
end
end
end
end
local animation1
local animation2
local function GunRun(PlayOrStop)
for i, v in pairs(Character:GetChildren()) do
if v:IsA("Tool") then
if v:FindFirstChild("Animations") and not animation2 then
animation2 = Humanoid:LoadAnimation(v:FindFirstChild("Animations").Run)
end
if v:FindFirstChild("AnimsFolder") and not animation1 then
animation1 = Humanoid:LoadAnimation(v:FindFirstChild("AnimsFolder").Run)
end
if PlayOrStop == "Play" then
if v:FindFirstChild("AnimsFolder") then --or v:FindFirstChild("Animations") then
if v:FindFirstChild("AnimsFolder").Run and animation1 then
animation1:Play()
end
elseif v:FindFirstChild("Animations") then
if v:FindFirstChild("Animations").Run and animation2 then
animation2:Play()
end
end
elseif PlayOrStop == "Stop" then
if v:FindFirstChild("AnimsFolder") then --or v:FindFirstChild("Animations") then
if v:FindFirstChild("AnimsFolder").Run and animation1 then
animation1:Stop()
end
elseif v:FindFirstChild("Animations") then
if v:FindFirstChild("Animations").Run and animation2 then
animation2:Stop()
end
end
end
end
end
end