Right after this line: local player = Players:GetPlayerFromCharacter(part.Parent)
add this: if player == nil then return end
If something other than a player’s body part touched the brick, then GetPlayerFromCharacter will return nil.
Sometimes the brick in one of your character’s accessories will trip it, and that will make player nil as well, unless you did GetPlayerFromCharacter(hit.Parent.Parent)
That’s why you should always add a check when it comes to .Touched events. Adding that line should fix it by stopping if there’s no player