Basically whats happening is that every time that i punch the output adds either 2 or 4 repeats of the code running so the damage is multiplied
local script:
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:FindFirstChild("Humanoid")
local CyborgM1Anim = hum:LoadAnimation(script.CyborgM1)
local debouce = false
local debouncev2 = false
CyborgM1Anim.Priority = Enum.AnimationPriority.Action2
game.UserInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if player:GetAttribute("Power") == "Cyborg" then
if player:GetAttribute("Stunned") == false then
if debouce == false then
debouce = true
CyborgM1Anim:Play()
local guiclone = script.CyborgM1GUI:Clone()
guiclone.Parent = player.PlayerGui
game.TweenService:Create(guiclone.PunchFrame, TweenInfo.new(2.5, Enum.EasingStyle.Linear), {Size = UDim2.new(0,1,0,25)}):Play()
CyborgM1Anim:GetMarkerReachedSignal("hitreg"):Connect(function()
print("punched")
local hitboxevent = game.ReplicatedStorage.Remotes.Cyborgs.M1
hitboxevent:FireServer(char, debouncev2)
end)
task.wait(2.5)
debouce = false
guiclone:Destroy()
end
end
end
end
end)
server script:
local rs = game.ReplicatedStorage
local Vfx = rs:FindFirstChild("VFX")
local cyborgs = rs.Remotes.Cyborgs
local cyborgm1 = cyborgs.M1
cyborgm1.OnServerEvent:Connect(function(player, char, able)
local hum = char:FindFirstChild("Humanoid")
local root = char:FindFirstChild("HumanoidRootPart")
local hitbox = Instance.new("Part")
hitbox.Parent = char
hitbox.Size = Vector3.new(3,3,3)
local weld = Instance.new("Weld")
weld.Parent = hitbox
weld.C0 = CFrame.new(0,0,2)
weld.Part0 = hitbox
weld.Part1 = root
hitbox.Transparency = 1
hitbox.CanCollide = false
game.Debris:AddItem(hitbox,0.2)
game.Debris:AddItem(weld,0.2)
local parts = workspace:GetPartsInPart(hitbox)
for i, v in ipairs(parts) do
if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= char then
if able == false then
able = true
local target = v.Parent
local vfx = Vfx:FindFirstChild("Cyborgs"):FindFirstChild("Explosion (*)"):FindFirstChild("Explosion"):Clone()
vfx.Parent = char:FindFirstChild("Right Arm"):FindFirstChild("RightGripAttachment")
game.Debris:AddItem(vfx,0.1)
target.Humanoid:TakeDamage(10)
end
end
end
end)