Need help making an "Infinite Health" gamepass

Hey there, I am making a story game and I wanted to create an infinite health gamepass. I tried to mess around and change stuff in my double health gamepass but it did not work. Can anyone help me with it?

2 Likes

Use MarketplaceService:UserOwnsGamePassAsync, Players.PlayerAdded and Player.CharacterAdded for this.


Players.PlayerAdded:Connect(function(player)
    local success, isOwned = xpcall(function()
        return MarketplaceService:UserOwnsGamePassAsync(id) --[[ call the function to check if 
they own the gamepass and return the result/bool]]
    end, warn)

    if not success or not isOwned then
        return -- don't do anything else if player doesnt own gamepass or something went wrong
    end

    player.CharacterAdded:Connect(function(char)
        -- set humanoid health to math.huge
    end)
end)

What do you mean by this?image

In the first line it’s connecting a CharacterAdded event, the function will fire whenever the player’s character is added.

The second line is where you’d make the player’s health infinite (math.huge)

And the last line is where it’s ending the function.

1 Like

You have to set the MaxHealth then the Health.

Make sure theres no Humanoid.Health = 0 in your code or it will bypass the math.huge value and kill the player.

I already know, that was just a example.

local gamepassID = 12345678 --// Gamepass ID here

local MarketPlaceService = game:GetService("MarketPlaceService")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        local success, err = pcall(function()
            return MarketPlaceService:UserOwnsGamePassAsync(gamepassID)
        end)

        if success then
            char.Humanoid.MaxHealth = math.huge
            char.Humanoid.Health = char.Humanoid.MaxHealth
        else
            warn(err)
            return err
        end
    end)
end)

MarketPlaceService isn’t a function it’s a Instance and I’m pretty sure it doesn’t have a __call metamethod on it (I don’t even know if services have metatables) so this wouldn’t work.

Mistake lemme fix XD Sorry :grinning_face_with_smiling_eyes: