Cannot damage other players?

So I want to try and mix up this gun set, but for some reason, this version I made has changed and I can no longer kill anybody, I beleive this is the cause, but have 0 clue how to fix it, any help?

local module = {}

module.CanDamage = function(obj, player)
	if obj:FindFirstChild("Humanoid") then
		local p = game.Players:GetPlayerFromCharacter(obj)
		local creator = obj:FindFirstChild("Creator")
		if creator then
			p = creator.Value
		end
		if p then
			if p == player then
				return false
			else
				if p.Neutral or player.Neutral then
					return true
				elseif p.TeamColor ~= player.TeamColor then
					return true
				end
			end
		else
			return true
		end
	end
	return false
end

return module
2 Likes

I suggest adding prints to the code so you can see what is and what isn’t running. Not much can be done unless you know where your code is getting to.

1 Like

Well its the fact that I cannot damage teamates it seems. So how do I fix this.

1 Like

There is a line in the code that checks the TeamColor of the player you are trying to damage. Removing that should fix your issue.

1 Like

I did that, tried fixing the end parts, and it just made it so I couldn’t kill anyone, no output errors.

1 Like

What do you mean “tried fixing the end parts”. What does the code look like now after you tinkered with it?

1 Like

I redid the code so it was original, i do not have the unworking one.

1 Like
if p.Neutral or player.Neutral then
	return true
elseif p.TeamColor ~= player.TeamColor then
	return true
end

If you don’t care what team they are on then these lines here seem quiet useless. Replace those lines with return true so it allows the damage.

1 Like