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

How to make a health gamepass?

Hello, In my game I am trying to make a extra health game pass witch gives you 200 health instead of 100. My script is not working do you have any ideas?

local id = 6751836
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
        plr.Character.Humanoid.Health = 200
    end
end)
 
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
            game.Workspace:WaitForChild(plr.Name):WairForChild("Humanoid").Health = 200
        end
    end)
end)

3 comments

0

At line 11, 'WairForChild' is not a method. I think you meant 'WaitForChild'. Remember to include the error in the thread next time.

0

Line 11 can be reduced to char.Humanoid.Health = 200 because 'char' is the character that was added. Remember that you don't need to wait for Humanoid because CharacterAdded fires after the Humanoid exists.

0

Where did you put this?

1 answer

✓ Accepted answer

You didn't put MaxHealth and You put "WairForChild" and not "WaitForChild". Here is the script:

local id = 6751836
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
        plr.Character.Humanoid.Health = 200
    end
end)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
	 game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").MaxHealth = 200
            game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").Health = 200
        end
    end)
end)

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