Im using a combo script to send the attack streak from a local script to a server script and play the proper attack animation while also doing damage to the player the blade touches. The problem is when more than one signal is sent to the script, it doesn’t properly finish the damage function.
Combo Sending Function (Local Script):
local function Attack()
for _,weapon in pairs(righthand:GetChildren()) do
if weapon:FindFirstChild("Handle") then
local swordtype = weapon:FindFirstChildOfClass("StringValue")
print("sent")
ComboSender:FireServer(swordtype, weapon, Streak, Mouse.Hit) -- Streak increases the more you attack before combo timer resets
end
end
end
Streak Receiver (Server Script):
---- Streak Handler ----
if Streak == 1 then
ATK1:Play()
DoDamage(weapon, Mouse)
elseif Streak == 2 then
ATK2:Play()
DoDamage(weapon, Mouse)
elseif Streak == 3 then
wait(.2)
ATK3:Play()
DoDamage(weapon, Mouse)
elseif Streak == 4 then
wait(.2)
ATK4:Play()
DoDamage(weapon, Mouse)
elseif Streak == 5 then
wait(.5)
ATK5:Play()
DoDamage(weapon, Mouse)
Attacking.Value = false
end
Damage Function (Server Script):
function DoDamage(weapon, Mouse)
local Blade = weapon:FindFirstChild("Blade")
---- DMG Amount ----
local MinDMG = weapon:FindFirstChild("MinDMG")
local MaxDMG = weapon:FindFirstChild("MaxDMG")
local AtkDMG = math.floor(math.random(MinDMG.Value,MaxDMG.Value))
---- Face Attack Direction ----
local ATKGyro = Instance.new("BodyGyro")
ATKGyro.Parent = char.HumanoidRootPart
ATKGyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
ATKGyro.D = 100
ATKGyro.P = 10000
ATKGyro.CFrame = CFrame.new(Vector3.new(0, 0, 0), Mouse.LookVector * Vector3.new(1, 0, 1))
debris:AddItem(ATKGyro,.1)
---- Do Damage ----
local CanDamage = true
Blade.Touched:Connect(function(part)
if CanDamage then
CanDamage = false
local Target = part.Parent:FindFirstChild("Humanoid")
if Target then
print("fighting")
Target:TakeDamage(AtkDMG)
end
end
end)
end
Video:
As you can see, the blade does damage even after nothing is touched, this happens when the attack button is pressed rapidly more than once.
I can provide more code if needed