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

Kicking someone for exploiting health function?

So basically, when a player god modes themselves, their health is "1.#INF" in Humanoid. I tested this and it didn't work. Any problems with it? Nothing came up on the dev console.

local infHealth = "1.#INF"


game.Workspace.ChildAdded:connect(function(Child)
	local Humanoid = Child:FindFirstChild("Humanoid")
	local Player = game.Players:FindFirstChild(Child.Name)
	
	if Humanoid then
		Humanoid.Changed:connect(function()
			if Player and Humanoid.MaxHealth == infHealth then
				Player:Kick("You have lost connection to the game")
			end
		end)
	end
end)

2 comments

0

Suggest to just check if its bigger then 1000 or so.

0

Really you could just check if it is greater than 100.

1 answer

✓ Accepted answer

Well first off, 1.#INF is a number, not a string. Yes, it appears as a string of characters, but it represents an infinite numeric value. You could test this by using type to get it's data type:

-- math.huge is a constant that's meant to represent an infinite quantity.
print(math.huge) -- > 1.#INF
print(type(math.huge)) -- > number

What you should be doing, is comparing the MaxHealth value to math.huge (assuming the "god health" has been set to this value). You should see a change in result after implementing that comparison. For example: if human.MaxHealth == math.huge then ... , etc. Hope this helped, let me know if you have any questions.

1 comment

0

Instead of relying on humanoid health just make an double value and plqce it in the player model

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