My gun can not shoot players with morphs on

Hello, I have been working on morphs and a gun system for the last week.
When I tested the guns with a player that had a morph on, the gun did no damage at all.

This is how the morph works when put on the player.

Screenshot_38

Then this is the gun script for damaging the player.

local function hit(plr, part)
–//Initialize || Checks
if not canShoot() then return end
if not part then return end

--//Get humanoid root part
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")

if rootPart then
	--//Check distance
	if (rootPart.CFrame.p - part.CFrame.p).magnitude <= range.Value then --//Check range
		--//Get humanoid
		local humanoid
		
		--//Check if part was a hat/acessory
		if part.Name == "Handle" then
			humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
		else
			humanoid = part.Parent:FindFirstChild("Humanoid")
		end
		
		
		if humanoid and humanoid.Health > 0 then --//Do nothing if humanoid is dead
			local newDamage = damage.Value
			
			--//Check hit
			if part.Name == "Head" then
				newDamage = newDamage * headMultiplier.Value
				
				--//Headshot related handling
				local soundCopy = headshotSound:Clone()
				soundCopy.Parent = part
				soundCopy:Play()
			end
			
			--//Apply damage
			humanoid:TakeDamage(newDamage)
		end
	end
end

end

Also side note, there is a headshot bonus, and it did not work either.

The parts being hit are within a model therefore you’re incorrectly defining the character and humanoid.

Instead, try:

local humanoid = part.Parent:FindFirstChild("Humanoid")
if not humanoid then
	humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
	-- Do your stuff
end
2 Likes

I’m not sure if this is correct but it looks like in the morph the body parts are in a model. In your script part.Parent:FindFirstChild(“Humanoid”) which would check if the humanoid was inside of the model instead the character model.

Solution
do part.Parent.Parent:FindFirstChild(“Humanoid”)

edit just saw @ForeverHD has already said this

I put it like this, still does not work.

local function hit(plr, part)
–//Initialize || Checks
if not canShoot() then return end
if not part then return end

--//Get humanoid root part
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")

if rootPart then
	--//Check distance
	if (rootPart.CFrame.p - part.CFrame.p).magnitude <= range.Value then --//Check range
		--//Get humanoid
		local humanoid = part.Parent:FindFirstChild("Humanoid")
		
		--//Check if part was a hat/acessory
		if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild("Humanoid")

end
if humanoid then

		if humanoid and humanoid.Health > 0 then --//Do nothing if humanoid is dead
			local newDamage = damage.Value
			
			--//Check hit
			if part.Name == "Head" then
				newDamage = newDamage * headMultiplier.Value
				
				--//Headshot related handling
				local soundCopy = headshotSound:Clone()
				soundCopy.Parent = part
				soundCopy:Play()
			end
			
			--//Apply damage
			humanoid:TakeDamage(newDamage)
		end
	end
end
end
end

How does your gun work?
Does it use raycasts?

Also, since your morphs insert models inside the player, try using:

local human = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")

if human then
 --Do something here.
end