I have a combat system in my game and everything works fine, but there is one thing thats still bad,the enemy gets damage just by touching.Here are the scripts (local and server): Please i need help with that
Local:
local UserInputService = game:GetService("UserInputService")
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = Char.Humanoid
local Hit = script:WaitForChild('Hit')
local CoolDown = 1
local Re = game:GetService("ReplicatedStorage").Combat
local Punch = game:GetService("ReplicatedStorage").PunchR15
local PunchR152 = game:GetService("ReplicatedStorage").PunchR152
local Punch2 = game:GetService("ReplicatedStorage").PunchR6
local Kick = game:GetService("ReplicatedStorage").KickR15
local Debounce = true
local Key = 'Q'
local ContextActionService = game:GetService("ContextActionService")
UserInputService.InputBegan:Connect(function(input, Istyping)
if Istyping then return end
if input.KeyCode == Enum.KeyCode[Key] and Debounce and Char then
Debounce = false
if script.Combo.Value == 1 then
print(script.Combo.Value)
script.Combo.Value = 2
local Load = Humanoid:LoadAnimation(Punch,Punch2)
Load:Play()
local damage = script.Damage.Value
Re:FireServer(damage)
elseif script.Combo.Value == 2 then
print(script.Combo.Value)
script.Combo.Value = 3
local Load = Humanoid:LoadAnimation(PunchR152)
Load:Play()
local damage = script.Damage.Value
Re:FireServer(damage)
elseif script.Combo.Value == 3 then
print(script.Combo.Value)
script.Combo.Value = 1
local Load = Humanoid:LoadAnimation(Kick)
Load:Play()
local damage = script.Damage.Value
Re:FireServer(damage)
end
wait(CoolDown)
Debounce = true
end
end)
ServerScript:
local Combat = game:GetService("ReplicatedStorage").Combat
Combat.OnServerEvent:Connect(function(plr,damage)
local Char = plr.Character or plr.CharacterAdded:Wait()
if not Char.Keybind.Hit.Value then
Char.Keybind.Hit.Value = true
local A = true
Char.RightHand.Touched:Connect(function(h)
if A and h.Parent.Name ~= plr.Name and h.Parent:FindFirstChild('Humanoid')and not h.Parent:FindFirstChild("AlreadyHit "..plr.Name) then
A = false
local AlreadyHit = Instance.new("BoolValue")
AlreadyHit.Name = "AlreadyHit "..plr.Name
AlreadyHit.Parent = h.Parent
game.Debris:AddItem(AlreadyHit,1)
local E = h.Parent.Humanoid
local s = script.Sound:Clone()
s.Parent = h
s:Play()
E:TakeDamage(damage)
print("take"..damage)
wait(3)
s:Remove()
A = true
end
end)
wait()
Char.Keybind.Hit.Value = false
end
end)
Thank you!

4 comments
Trying changing the and not h.Parent:FindFirstChild("AlreadyHit " .. plr.Name) to and h.Parent:FindFirstChild("AlreadyHit " .. plr.Name) == nil then
Shouldn’t the enemy get damaged if the players arm touches the enemy? What do you mean just by touching?
Ohhh I know what you mean.
Keep A false after the touches event is done. Don’t set it back to true cause then the touches event will run event if it’s in the if statement.