I made this hit box and damage script, and once it executes it damages the enemy player. But sometimes when i execute it, it damages the player, and not the enemy player, any help?
--Hitbox to do damage
local Hitbox = Instance.new("Part", game.Workspace)
Hitbox.Anchored = false
Hitbox.CanCollide = false
Hitbox.Transparency = 1
Hitbox.BrickColor = BrickColor.new("Bright red")
Hitbox.Size = Vector3.new(1.3, 1.3, 1.3)
local Weld = Instance.new("Weld", Hitbox)
Weld.Part0 = Hitbox
Weld.Part1 = Character.LeftHand
Weld.C0 = Weld.C0 * CFrame.new(0, 0, 0)
--Damage
Hitbox.Touched:connect(function(p)
if script.CanDamage.Value == true then
script.CanDamage.Value = false
p.Parent.Humanoid:TakeDamage(Player.Data.Strength.Value+5)
print("Hit")
--Effect
for i = 1,5 do
local Effect2 = game.ReplicatedStorage.MeshEffects.SpinningCircle:Clone()
Effect2.BrickColor = BrickColor.new("Medium stone grey")
Effect2.Size = Vector3.new(3, 3, 3)
Effect2.Parent = game.Workspace
Effect2.CFrame = p.Parent.LowerTorso.CFrame * CFrame.Angles(0, math.random(-90, 90), 0)
end
end
end)
