Humanoid wont Damage

Whatever I do trying to take damage from the health of the humanoid it just won’t work. I’ve tried -= and :TakeDamge() and none of those have worked. Can someone please help me with this?

local Remote = script.Parent.Fire

Remote.OnServerEvent:Connect(function(player, MousePos)
	
	local Bullet = Instance.new("Part")
	Bullet.Parent = workspace
	Bullet.CanCollide = false
	Bullet.Anchored = false
	Bullet.Material = Enum.Material.Neon
	Bullet.BrickColor = BrickColor.new("Cyan")
	Bullet.Shape = Enum.PartType.Ball
	Bullet.Size = Vector3.new(1.25,1.25,1.25)
	Bullet.CFrame = script.Parent.Handle.BallPosition.CFrame
	

	local NewForce = Instance.new("BodyForce")
	NewForce.Force = Vector3.new(0,workspace.Gravity * Bullet:GetMass(),0)
	NewForce.Parent = Bullet

	Bullet.Velocity = CFrame.new(player.Character.HumanoidRootPart.Position, MousePos).LookVector * 150
	
	local Debounce = true
	
	Bullet.Touched:Connect(function(hit)		
		local boss = hit.Parent
		if boss.Name == "rytansaltheboss" and Debounce then
			print("yes")
			Debounce = false
			
			local effect = Instance.new("Part")
			effect.Parent = workspace
			effect.Position = Bullet.Position
			effect.Anchored = true
			effect.CanCollide = false
			effect.Size = Vector3.new(1,1,1)
			effect.Material = Enum.Material.Neon
			effect.BrickColor = BrickColor.White()
			effect.Shape = Enum.PartType.Ball
			effect.CastShadow = false
			game:GetService("TweenService"):Create(effect,TweenInfo.new(0.5),{
				Transparency = 1,
				Size = Vector3.new(10,10,10)
			}):Play()
			local hum = boss:FindFirstAncestorWhichIsA("Humanoid")
			hum:TakeDamage(math.random(20,30))
			print("yessed")
			Bullet.Transparency = 1
			task.wait(0.5)
			effect:Destroy()
			Bullet:Destroy()
		end
	end)
	
	spawn(function()
		task.wait(10)
		if Bullet then
			Bullet:Destroy()
		end
	end)
end)

Just to double check - does “yessed” print? (just making sure the line is actually reached)

no it doesn’t, but i’ve figured out the issue, if i switch it with waitforchild it works. But why? And after i fixed it, it does print now.

Which line in particular did you add WaitForChild to?

			local hum = boss:FindFirstAncestorWhichIsA("Humanoid")

FindFirstAncestor goes up in parentage. I imagine that you meant to get the first descendant (go down in parentage) which is a humanoid. Simplest way to do that would be to do :FindFirstChild("Humanoid"), although WaitForChild also works.

1 Like

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