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

God script problem?

this script is suppose to god the health of players on touched and dis-appear when not touched

but i think there are some errors

-noviced scripter

script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid") == nil then return end 		
script.Parent.Character.Humanoid.MaxHealth = math.huge
script.Parent.Character.Humanoid.Health = math.huge
			end) 
		

2 answers

✓ Accepted answer

The problem is

script.Parent.Character.Humanoid.MaxHealth = math.huge
script.Parent.Character.Humanoid.Health = math.huge

You are saying that the scripts Parent is the Player that touched it. What you want is to get the Humanoid from the hit (which you did).

script.Parent.Touched:connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then -- if humanoid doesn't == false or nil then
		humanoid.MaxHealth = math.huge
		humanoid.Health = math.huge
	end
end)

3 comments

0

Yeah but 1 problem how to turn it back to normal if u aint touching it

0

Oh for that you would use TouchEnded. Also I suggest adding a debounce so it isn't constantly changing the humanoids health.

0

tried putting debounced still the same

Unless you have the player grouped into a model with a part, I think you'll want to change lines 3 and 4 to

hit.Parent.Humanoid.MaxHealth = math.huge
hit.Parent.Humanoid.Health = math.huge

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