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

why is my gamepass handler not giving players the items?

Asked by
MHaven1 159
7 years ago
pcall(function()
    game.Players.PlayerAdded:connect(function(player)
        if game.GamePassService:PlayerHasPass(player,574426548) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 10
                    char.Humanoid.Health = char.Humanoid.Health + 10
                    game.Lighting.WoodenSword:Clone().Parent=player.Backpack
                end
            end)
        elseif game.GamePassService:PlayerHasPass(player,574427239) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 25
                    char.Humanoid.Health = char.Humanoid.Health + 25
                    game.Lighting.SubspaceTripmine:Clone().Parent=player.Backpack
                end
            end)
        elseif game.GamePassService:PlayerHasPass(player,574430612) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 50
                    char.Humanoid.Health = char.Humanoid.Health + 50
                    game.Lighting.EpicKatana:Clone().Parent=player.Backpack
                end
            end)
        elseif game.GamePassService:PlayerHasPass(player,574437515) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 75
                    char.Humanoid.Health = char.Humanoid.Health + 75
                    game.Lighting.RayGunBio:Clone().Parent=player.Backpack
                end
            end)
        elseif game.GamePassService:PlayerHasPass(player,574439700) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 100
                    char.Humanoid.Health = char.Humanoid.Health + 100
                    game.Lighting.Phoenix:Clone().Parent=player.Backpack
                end
            end)
        elseif game.GamePassService:PlayerHasPass(player,574441188) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 200
                    char.Humanoid.Health = char.Humanoid.Health + 200
                    game.Lighting["Ro-Orb"]:Clone().Parent=player.Backpack
                    game.Lighting.Darkheart:Clone().Parent=player.Backpack
                end
            end)
        end
    end)
end)

script will not give the player what he bought please help.

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

The way your code is written, the first gamepass that the Player has purchased, in the order you have typed them, is the only one they get. elseif doesn't trigger if a previous if or elseif in the same 'tree' triggered:

pcall(function()
    game.Players.PlayerAdded:connect(function(player)
        if game.GamePassService:PlayerHasPass(player,574426548) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 10
                    char.Humanoid.Health = char.Humanoid.Health + 10
                    game.Lighting.WoodenSword:Clone().Parent=player.Backpack
                end
            end)
        end
if game.GamePassService:PlayerHasPass(player,574427239) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 25
                    char.Humanoid.Health = char.Humanoid.Health + 25
                    game.Lighting.SubspaceTripmine:Clone().Parent=player.Backpack
                end
            end)
        end
    if game.GamePassService:PlayerHasPass(player,574430612) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 50
                    char.Humanoid.Health = char.Humanoid.Health + 50
                    game.Lighting.EpicKatana:Clone().Parent=player.Backpack
                end
            end)
        end
    if game.GamePassService:PlayerHasPass(player,574437515) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 75
                    char.Humanoid.Health = char.Humanoid.Health + 75
                    game.Lighting.RayGunBio:Clone().Parent=player.Backpack
                end
            end)
        end
    if game.GamePassService:PlayerHasPass(player,574439700) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 100
                    char.Humanoid.Health = char.Humanoid.Health + 100
                    game.Lighting.Phoenix:Clone().Parent=player.Backpack
                end
            end)
    end       
    if game.GamePassService:PlayerHasPass(player,574441188) then
            player.CharacterAdded:connect(function(char)
                if char:WaitForChild("Humanoid") then
                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 200
                    char.Humanoid.Health = char.Humanoid.Health + 200
                    game.Lighting["Ro-Orb"]:Clone().Parent=player.Backpack
                    game.Lighting.Darkheart:Clone().Parent=player.Backpack
                end
            end)
        end
    end)
end)
0
ahhh ok ty MHaven1 159 — 7y
0
urm idk why but it sill will not give the items to the players and it doesnt change their health as well. MHaven1 159 — 7y
0
nvm fixed the problem it works now. MHaven1 159 — 7y
Ad

Answer this question