Does anyone know how i would change this animation module, its currently doesn’t work but I don’t think its a good system, how would I stop specific animations from playing and stop
local plr = game:GetService("Players").LocalPlayer
local chr = plr.Character
local animmodule = require(game:GetService("ReplicatedStorage").Modules.AnimationHandler)
chr:GetAttributeChangedSignal("WeaponEquipedAndHeld"):Connect(function()
local weaponheld = chr:GetAttribute("WeaponEquipedAndHeld")
if weaponheld == "" then
animmodule.PauseAnimations(plr)
animmodule.IdleAnim(plr,PlayerAnims)
else
animmodule.PauseAnimations(plr)
animmodule.IdleAnim(plr,weaponheld)
end
end)
local AnimsModule = {}
local replicatedfirst = game:GetService("ReplicatedFirst")
local animfolder = replicatedfirst:WaitForChild("Animations")
function AnimsModule.M1anim(player,WeaponName,CombatNum)
print(player)
print(WeaponName)
print(CombatNum)
local combatnum = Instance.new("StringValue")
combatnum.Value = CombatNum
combatnum.Name = "combatnum"
for i,v in animfolder:GetChildren() do
if v.Name == WeaponName then
for i,s in v:GetChildren() do
if s.Name == "M1" then
print("M1 WORKS")
for i,A in s:GetChildren() do
if A.Name == combatnum.Value then
print("IT RUN")
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:FindFirstChildOfClass("Humanoid")
local animtrack = humanoid:LoadAnimation(A)
animtrack:Play()
end
end
end
end
end
end
end
function AnimsModule.IdleAnim(player,WeaponName)
for i,v in animfolder:GetChildren() do
if v.Name == WeaponName then
for i,s in v:GetChildren() do
if s.Name == "Idle" then
local anim = s.Idle
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:FindFirstChildOfClass("Humanoid")
local animtrack = humanoid:LoadAnimation(anim)
animtrack:Play()
--animtrack.Looped = true
end
end
end
end
end
function AnimsModule.PauseAnimations(player,WeaponName)
for i,v in animfolder:GetChildren() do
for i,s in v:GetChildren() do
for i,a in s:GetChildren() do
for i,j in a:GetChildren() do
j:Stop()
end
end
end
end
end
return AnimsModule