so i was trying to make a combat system specifically playing the right animations
issue is that, when I press mouse button 1 , it runs the script twice, when I only want it to run once per mouse button 1 pressed. secondly no animations are playing, and there isn’t any error message
I have two scripts, a local and a module
local uis = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local chr = player.Character
local hum = chr:WaitForChild("Humanoid")
local ListoFWeapons = {
"BasicSword",
"RengokuSword",
"PlaceHolder1",
}
local module = require(rs:WaitForChild("Modules").CombatSystemModule)
local CombatNum = 1
uis.InputBegan:Connect(function(input,e)
if e then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
for i,v in player.Character:GetChildren() do
if v.Name == "BasicSword" or v.Name == "RengokuSword" and v:IsA("MeshPart") then
print("this work")
module.CombatSystem(player,CombatNum)
CombatNum += 1
if CombatNum > 3 then
CombatNum = 1
end
end
end
end
end)
and the modulecript is
local module = {}
module.CombatSystem = function(player,CombatNum)
local char = player.Character
local hum = char:WaitForChild("Humanoid")
for i,v in game:GetService("ReplicatedFirst").Animations.KatanaM1s:GetChildren() do
if v.Name == CombatNum then
print(CombatNum)
local KatanaCombat = hum:LoadAnimation(v)
KatanaCombat:Play()
end
end
end
return module
Below is the folder with animations