Humanoid isn't taking damage

Hello there,

I am trying to get my game to take damage so that it breaks (It’s a destructible gate) but the Humanoid doesn’t seem to be taking any damage. Does anyone know how to fix it? All help is appreciated.

How it's set up

image

Code
cv=0
local Humanoid = workspace.FullGateSet.GateSet.Humanoid
while true do
	wait()
	cv=cv+((script.Parent.Health.Value-cv)*0.2)
	perc=cv/script.Parent.maxHealth.Value
	if perc<.01 then
		script.Parent.Display.Enabled=false
	else
		script.Parent.Display.Enabled=true
	end
	script.Parent.Display.Green.Size=UDim2.new(perc,0,1,0)
	script.Parent.Display.Green.BackgroundTransparency=1-perc
	if perc<0.0001 then
		script.Parent.Transparency=1
		script.Parent.CanCollide=false
	wait (30)
	script.Parent.Display.Green.Size=UDim2.new(perc,0,1,0)
	script.Parent.Display.Green.BackgroundTransparency=1-perc
	script.Parent.Transparency=0
	script.Parent.Health.Value=100
	Humanoid:TakeDamage(10)
	script.Parent.CanCollide=true
	else
		script.Parent.Transparency=0
		script.Parent.CanCollide=true
	end
end
Gate File

Gate.rbxm (9.2 KB)

Was my solution in the previous question sufficient, or is this a new issue?

1 Like

This is a different issue.

The last one was a issue about not being able to hit the gate. Now I can hit it but the gate doesn’t take any damage.

What are you hitting it with?

1 Like

My Axe.

image

What is the hit and damage code?

1 Like

I have one inside the axe to hit a humanoid. Which it does, and makes a hitting noise when I use it on the gate. But the gate doesn’t seem to loose health.

Do you want the hit and damage code of the tool or gate.

Humanoid:TakeDamage only works when a part named Torso is present in the model the Humanoid is in. I would simply subtract 10 from the humanoids health manually instead.

3 Likes

The tool damage is what is probably the issue, so that code.

1 Like
local function onHit(hit)
	if not collide then
		if hit.Name == "Blade" or hit.Name == "Shield" or hit.Name == "ParryPart1" then
			collide = true
			if cAnim then
				cAnim:AdjustSpeed(0)
			end
			comm({2, "clash", 1, 1 + math.random(-10, 10) / 80})
			if blade:findFirstChild("Sparks") then
				blade.Sparks:Emit(8)
			end
			if hit.Parent:findFirstChild("Core") and hit.Parent.Core:findFirstChild("Comm") then
				hit.Parent.Core.Comm:FireServer({7, damage})
			end
		elseif hit.Parent and hit.Parent:findFirstChild("Humanoid") and hit.Name ~= "HumanoidRootPart" then
			comm({1, hit.Parent.Humanoid, damage, hitForce, torso.Position})
			comm({2, "hit", 1, 1 + math.random(-10, 10) / 80})
			if blade:findFirstChild("Blood") then
				blade.Blood:Emit(5)
			end
		end
	end
end

Where does it actually do the damage, though?

1 Like

There is a local damage at the top of the script which is set to 13. And a local hitforce. Otherwise that’s where the damage is.

elseif hit.Parent and hit.Parent:findFirstChild("Humanoid") and hit.Name ~= "HumanoidRootPart" then
			comm({1, hit.Parent.Humanoid, damage, hitForce, torso.Position})
			comm({2, "hit", 1, 1 + math.random(-10, 10) / 80})
			if blade:findFirstChild("Blood") then
				blade.Blood:Emit(5)
			end

That should be what does the damage. Damage is defined as 13

There’s nothing there that actually does anything to the humanoid, though. You need to tell it to do actually change something, like in the ways I mentioned in the other post.

2 Likes

I believe he’s asking about the comm function, to see how you handle damaging.

1 Like

Yeah I am using a Remote Function inside the tool. Comm is the name of the Remote Function.

So comm = RemoteFunction:InvokeServer/Client?

1 Like

It is generally a good idea to have any damage variable server-side only, rather than having the client send in through remote event (don’t trust the client). I suggest centralizing those damage variables (for all weapons you may add) into a table on the server side script that handles the damage remote event.

3 Likes