For a while I have been messing around and tweaking this script, and I've even looked at other people's scripts to see if they are doing something that I'm missing, but I just can't seem to find anything. On top of that, I don't receive any errors, so I'm not sure what's going wrong with it.
UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CombatSystem = ("DamageModule")
local plr = game.Players.LocalPlayer
local char = plr.Character
local humanoid = game:FindFirstChild("HumanoidRootPart", true)
local module = require(script.Parent.DamageModule)
local Debounce = true
Key = "H"
Key2 = "J"
Key3 = "K"
Key4 = "L"
local SwingCount = 0
local SwingCount2 = 0
-- Light attack sequence (Measures magnitude between Attacker's body part(s) and HumanoidRootPart of other player)
script.DamageEvent.OnServerEvent:connect(function()
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode[Key] and Debounce then
SwingCount = SwingCount + 1
if SwingCount == 1 then
local touched = char.LeftHand.touched:Connect(function(tap)
if tap.Parent:FindFirstChild("HumanoidRootPart") and tap.Parent ~= char.Name and not tap.Parent:FindFirstChild("HumanoidRootPart") then
if (char.RightHand.Position - tap.Parent.HumanoidRootPart.Position).magnitude <= 6 then
tap.Parent.humanoid:TakeDamage(3)
elseif SwingCount == 2 then
local touched = char.RightHand.touched:Connect(function(tap)
if tap.Parent:FindFirstChild("HumanoidRootPart") and tap.Parent ~= char.Name and not tap.Parent:FindFirstChild("HumanoidRootPart") then
if (char.HumanoidRootPart.Position - tap.Parent.HumanoidRootPart.Position).magnitude <= 6 then
tap.Parent.humanoid:TakeDamage(3)
elseif SwingCount == 3 then
local touched = char.LeftHand.touched:Connect(function(tap)
if tap.Parent:FindFirstChild("HumanoidRootPart") and tap.Parent ~= char.Name and not tap.Parent:FindFirstChild("HumanoidRootPart") then
if (char.HumanoidRootPart.Position - tap.Parent.HumanoidRootPart.Position).magnitude <= 6 then
tap.Parent.humanoid:TakeDamage(3)
elseif SwingCount == 4 then
local touched = char.LeftHand.touched:Connect(function(tap)
if tap.Parent:FindFirstChild("HumanoidRootPart") and tap.Parent ~= char.Name and not tap.Parent:FindFirstChild("HumanoidRootPart") then
if (char.HumanoidRootPart.Position - tap.Parent.HumanoidRootPart.Position).magnitude <= 6 then
tap.Parent.humanoid:TakeDamage(5)
end
end
end)
end
end
end)
end
end
end)
end
end
end)
end
end
end)

1 comment
My apologies for the cut off, not sure why that happened. If you feel like you're missing out on details just ask