Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my script saying that the Health value of a Humanoid is ALWAYS 100, even when it isn't?

Okay, re-explanation. The npc hits a pad which takes away however much health it has from the "ROBLOX" value. However, it takes away 100, even if the NPC's health is not 100.

function hitdetection(hit)
	if hit.Parent.Name=="Guest" then
		local newvalue=game.Workspace.ROBLOX.Value-hit.Parent.Humanoid.Health
		print(newvalue)
		game.Workspace.ROBLOX.Value=newvalue
	hit.Parent:Destroy()
	end
end








local canfire=true
game.Workspace.End1.Touched:connect(function(hit)
	if canfire==true then
		canfire=false
		hitdetection(hit)
		wait (0.1)
		canfire=true
	end
end)

2 comments

0

i have the same problem

0

@botw_legend this is a year old post.

1 answer

Health data is stored in the Humanoid object, last time I checked. Modify it there to reduce clutter, or use variables.

-- on the 'damage' pad
-- plrTouched = the player who touced, I'm not sure how you're detecting that
local healthToRemove = 20

plrTouched.Humanoid.Health = plrTouched.Humanoid.Health - healthToRemove

4 comments

0

What? Two things. 1: This isnt even for players, its for an NPC (as stated above) 2: This script doesn't take away damage from the Humanoid. It takes away the Humanoid's health from the "ROBLOX" value in the Workspace.

0

Uh, 1: same shit, it works for both, 2: I didn't realize, why on earth have a seperate value?

0

I said 'modify it there' for a reason, and that's because you wouldn't want a seperate value its bad design.

0

No, I have a seperate value because its game specific. Im still not removing the characters health

This discussion is preserved as it was. New answers, comments, and votes are closed.