Hi I’m trying to make a side melee system for my weapons and it goes smooth but with a little additional touch delay error.
Basically I want to make two sounds which one is for a fist swing sound and another for a struck sound and the problem is where if I do a swing but then touch a humanoid it still has the previous function which should had ended.
This is what it looks like which has an additional damage which shouldn’t happened:
This is the server script I made:
local function Weapon_Melee_Function()
local Weapon_Melee_Sound = Weapon_Sounds:WaitForChild("Weapon_Melee_Sound")
Weapon_Melee_Sound:Clone().Parent = Handle.Parent.Parent:FindFirstChild("Left Arm")
Handle.Parent.Parent:FindFirstChild("Left Arm"):FindFirstChild("Weapon_Melee_Sound"):Play()
Handle.Parent.Parent:FindFirstChild("Left Arm"):FindFirstChild("Weapon_Melee_Sound").Ended:Once(function()
Handle.Parent.Parent:FindFirstChild("Left Arm"):FindFirstChild("Weapon_Melee_Sound"):Destroy()
end)
Handle.Parent.Parent:FindFirstChild("Left Arm").Touched:Once(function(Weapon_Melee_Function)
if Weapon_Melee_Function.Parent:FindFirstChild("Humanoid") then
print("Humanoid")
local Weapon_Struck_Sound = Weapon_Sounds:WaitForChild("Weapon_Struck_Sound")
Weapon_Struck_Sound:Clone().Parent = Handle.Parent.Parent:FindFirstChild("Left Arm")
Handle.Parent.Parent:FindFirstChild("Left Arm"):FindFirstChild("Weapon_Struck_Sound"):Play()
Handle.Parent.Parent:FindFirstChild("Left Arm"):FindFirstChild("Weapon_Struck_Sound").Ended:Once(function()
Handle.Parent.Parent:FindFirstChild("Left Arm"):FindFirstChild("Weapon_Struck_Sound"):Destroy()
end)
Weapon_Melee_Function.Parent.Humanoid.Health -= 5
end
end)
end
I have tried some stuff to move the touched function but still no luck.