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
8 years ago
01pcall(function()
02    game.Players.PlayerAdded:connect(function(player)
03        if game.GamePassService:PlayerHasPass(player,574426548) then
04            player.CharacterAdded:connect(function(char)
05                if char:WaitForChild("Humanoid") then
06                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 10
07                    char.Humanoid.Health = char.Humanoid.Health + 10
08                    game.Lighting.WoodenSword:Clone().Parent=player.Backpack
09                end
10            end)
11        elseif game.GamePassService:PlayerHasPass(player,574427239) then
12            player.CharacterAdded:connect(function(char)
13                if char:WaitForChild("Humanoid") then
14                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 25
15                    char.Humanoid.Health = char.Humanoid.Health + 25
View all 54 lines...

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
8 years ago
Edited 8 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:

01pcall(function()
02    game.Players.PlayerAdded:connect(function(player)
03        if game.GamePassService:PlayerHasPass(player,574426548) then
04            player.CharacterAdded:connect(function(char)
05                if char:WaitForChild("Humanoid") then
06                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 10
07                    char.Humanoid.Health = char.Humanoid.Health + 10
08                    game.Lighting.WoodenSword:Clone().Parent=player.Backpack
09                end
10            end)
11        end
12if game.GamePassService:PlayerHasPass(player,574427239) then
13            player.CharacterAdded:connect(function(char)
14                if char:WaitForChild("Humanoid") then
15                    char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 25
View all 59 lines...
0
ahhh ok ty MHaven1 159 — 8y
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 — 8y
0
nvm fixed the problem it works now. MHaven1 159 — 8y
Ad

Answer this question