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)
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.