How to make gate have health

Oh. that actually works. Finally, a 24 hour bag’s been solved! Thanks for helping, yall. I appreciate you guy’s help.

alrighty so ive been doin some testing and found out you can use tool.Activated in a server script :open_mouth:

so put this code in a serverScript inside the tool… if ur gonna use the NumberValue thing…

script.Parent.Activated:Connect(function()
local damaged = false
	script.Parent.Handle.Touched:Connect(function(hit)
		if hit:IsA("Part") or  hit:IsA("MeshPart")  then
			if hit.Name == "Gate"  then
				if hit:FindFirstChild("Health") and damaged == false then
					hit.Health.Value = hit.Health.Value - 10
					damaged = true
					wait(1)
					damaged = false
				end
			end
		end
	end)
end)
2 Likes

I may use it in the humanoid script. Thanks. :slight_smile:

1 Like

The sword itself also offers a way to detect when it’s static, in a short swing or undergoing a lunge, these can be used to deal different damages to the gate.

1 Like

Is there also a way to regenerate the wall, say like someone grabs a hammer and starts healing the gate by touching it?

Wait, nevermind I got that too.

Yes, just add another conditional statement which checks for a different tool & adds to the health of the Humanoid instance instead of removing from the health.

1 Like