Hitbox not detecting other players properly. mainly detects local player (Bump4)

I am trying to make a simple hitbox for my attack. for some reason it only detects the local player. it only detects the other player at a stupid position.

if you see in the first pic it only prints local player
the second pic shows how close I have to be for it to detect the second player

first pic:

second pic:

this is the code being used:

> local HB = Instance.new("Part")
> HB.Size = Vector3.new(3,6,5)
> HB.CanCollide = false
> HB.Color = Color3.fromRGB(255, 0, 0)
> HB.Transparency = 0.6
> HB.Anchored = true
> HB.CFrame = Char:FindFirstChild("Head").CFrame * CFrame.new(0,-1,-4)
>                 
> AttackingLoad:Play()
>                 
> HB.Parent = workspace
>                 
> Debris:AddItem(HB, 1)
>                 
> HB.Touched:Connect(function(Hit)
>                     
> local Target = PS:GetPlayerFromCharacter(Hit.Parent)
> 
> if not Target or Target == Player then warn("we hit local player") return end
>                     
> Attack(Target)
> 
> end)

the attack function just prints out the hit player for now
i get that im still trash at scripting but i dont see why it shouldnt work
btw this is a local script

I would suggest using print statements to debug and see if your code is working is intended. It is possible that your comparisons may not be working properly.

1 Like

the rest works. as you can see when I’m standing extremely close to the other player and attack it detects player 2. other than that it doesn’t detect