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

Is the code correct for the service that I need? (gamepass)

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

i want the door to open to these people OR if they own the gamepass (id: 285082790)

01    local allow = (
02        player.Name == "SimplyKol" or
03        player.Name == "play1885" or
04        player.Name == "Nick7cool" or
05        player.Name == "DarwinYork" or
06        player:IsInGroup(1107429) or
07        game:GetService('GamePassService'):UserHasGamePass(player.userId, 285082790) or
08        game.CreatorId == player.userId
09    )
10    if allow then
11        open()
12        delay(4.5, close)
13    end
14end)

more specifically

1game:GetService('GamePassService'):UserHasGamePass(player.userId, 285082790)

if it isn't correct then what is? im not getting an error but i still dont know if it works.

1 answer

Log in to vote
0
Answered by 9 years ago

This is actually pretty neat. Though I would create a function and a table to make things a little bit faster and easier to code:

01AllowedPlayers={"SimplyKol""play1885", "Nick7cool","DarwinYork"}
02 
03function CorrectPlayer(player)
04    for i,v in pairs (AllowedPlayers) do
05        if player.Name==v then
06            return true
07        end
08    end
09    return false
10end
11 
12    if CorrectPlayer(player) or  game:GetService('TShirtService'):UserHasTShirt(player.userId, 283727664) or game.CreatorId == player.userId then
13        open()
14        delay(4.5, close)
15    end
16end)

This will do the same thing as your code but it simplifies the player names you want so it is easier to add or remove names without having to write "if player.Name=="x" or player.Name=="y" or player.Name=="z" or..."

0
Thanks for the answer but I don't understand pairs or returning yet so I figured out the MarketPlaceService worked instead. DarwinYork 85 — 9y
0
Well, I could briefly explain them in a simple way if you want. They are easy to understand and a huge help in coding. BobserLuck 367 — 9y
Ad

Answer this question