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

Game Pass Help?

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

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

Answer this question