Creating a hitbox that doesn't account for the player

This is probably a very simple question. I am creating a hitbox. I understand how to create it and how to check if whatever is touching it has a humanoid and what not. What I don’t know is how to make it not account for the player actually creating the hitbox. Example is if player A is creating the hitbox and player B gets detected in said hitbox, I only want player B to be detected and not player A.

I wonder if this is right.

-- ServerScript
-- if this script is inside the server instance.
local Players = game:GetService("Players")
hitbox.Touched:Connect(function(playerA : Player, objectThatTouched))
    -- lets check if its a player.
    -- This will return the player or nil
    local playerB = Players:GetPlayerFromCharacter(objectThatTouched.Parent) 

    if playerB and playerA ~= playerB then
        -- logic here
    end
end)

I’ll use this and see if it ends up working. I’m sure it will. Thank you kind stranger.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.