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

Game Pass Help?

This is meant to change the player's max health but it doesn't work... Any help? Here's the script:

gps = Game:GetService("GamePassService")

gpid = 190345440 --Put the gamepass ID here


function respawned(char)
	player = game.Player:FindFirstChild(char.Name)
	if char:FindFirstChild("Head") ~= nil then
		if gps:PlayerHasPass(player, gpid)then
			function charHealth(char) 
				human = char:FindFirstChild("Humanoid") 
				if human then 
				human.MaxHealth = human.MaxHealth+100
				human.health = human.Health+100 
				end
			end
		end
	end
end)				

game.Players.PlayerAdded:connect(function(plyr) plyr.CharacterAdded:connect(charHealth) end)

1 answer

You don't need a function for charHealth, so you can just get rid of it and the end.

gps = Game:GetService("GamePassService")

gpid = 190345440 --Put the gamepass ID here


function respawned(char)
    player = game.Player:FindFirstChild(char.Name)
    if char:FindFirstChild("Head") ~= nil then
        if gps:PlayerHasPass(player,gpid) then
                human = char:FindFirstChild("Humanoid") 
                if human then 
               		human.MaxHealth = human.MaxHealth+100
               		human.health = human.Health+100 
            end
        end
    end
end --No need for a parenthesis round the end.              

game.Players.PlayerAdded:connect(function(plyr) plyr.CharacterAdded:connect(respawned) end) --Connect CharacterAdded to the respawned function.

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