Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a health gamepass?

Asked by 4 years ago
Edited 4 years ago

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)
0
At line 11, 'WairForChild' is not a method. I think you meant 'WaitForChild'. Remember to include the error in the thread next time. pidgey 548 — 4y
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. pidgey 548 — 4y
0
Where did you put this? Asher0606 36 — 4y

1 answer

Log in to vote
0
Answered by
rbaxc 15
4 years ago

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

Answer this question