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

God mode gamepass script how would i add that?

``Ok so first off how would i add a god mode to this script SO like you NEVER DIE :

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 9349044 --Replace this set of numbers with your gamepass id
 
function onPlayerSpawned(player) 
    
    local hasPass = false
 
    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
    end)
-- The script below is for checking whether or not the player has the gamepass.
    if not success then
        warn("Error while checking if player has pass: " .. tostring(message))
        return
    end
 
    if hasPass == true then

--GOD MODE

--END


3 comments

0

I belive the end is wrong

0

possibly set the player's health to math.huge?

0

you already asked this question?

1 answer

Hello there. Try using a CharacterAdded event with an if statement on if the player owns the gamepass. If they do, their MaxHealth and Health get changed to math.huge (infinite).

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 9349044 --Replace this set of numbers with your gamepass id

local function onPlayerAdded(player)
	local function onCharacterAdded(character)
		if MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID) then
			character.MaxHealth = math.huge
			character.Health = math.huge
		end
	end

	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

Please upvote and accept this answer if it helped.

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