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

How to make an if statement in a gamepass script?

Asked by
zomspi 541 Moderation Voter
5 years ago

How might I make a gamepass script so if the player owns the gamepass they get 4 money on kill and if they don't own the gamepass they get 2. I tried this but it didn't work:

    game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
    if game.MarketplaceService:PlayerOwnsAsset(player.UserId, 7187215) then

     game.Players.PlayerAdded:connect(function(p) 
     p.CharacterAdded:connect(function(c)

      c.Humanoid.Died:connect(function() 



    local cv = c.Humanoid:findFirstChild("creator") 

           if cv

             then 

              local k = cv.Value 


            if k and k ~= p then 

              k.leaderstats.Money.Value = k.leaderstats.Monaey.Value+4


                                        else

                     game.Players.PlayerAdded:connect(function(p) 

                       p.CharacterAdded:connect(function(c)

                      c.Humanoid.Died:connect(function() 

                     local cv = c.Humanoid:findFirstChild("creator") 
                        if cv

                             then 

                                   local k = cv.Value 
                                      if k and k ~= p then 

                                      k.leaderstats.Money.Value = k.leaderstats.Money.Value+2

                                             end  -- end k and k ~= p
                                             end -- end if cv

                                           end) -- c.Humanoid.Died:connect
                                           end) -- p.CharacterAdded:connect
                                         end) -- game.Players.PlayerAdded:connect(function(p)

                             end -- end if k and k ~= p then 
         end -- end if cv

            end) -- end the died:connect (again???)
            end) -- p.CharacterAdded:connect(function(c) (again???)
            end) --  game.Players.PlayerAdded:connect (again)???

    end --   if game.MarketplaceService:PlayerOwnsAsset(player,7187215) 





    end) --  player.CharacterAdded:Connect(function(character)
    end) -- game.Players.PlayerAdded:Connect(function(player)


The "--" is because someone helped me with it. Thanks if anyone can help!

1 answer

Log in to vote
0
Answered by 5 years ago

Take a look at this resource. https://developer.roblox.com/en-us/articles/Badges-Special-Game-Awards

Badges are not assets, they have their own special service :)

Ad

Answer this question