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 8 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)

    local allow = (
        player.Name == "SimplyKol" or
        player.Name == "play1885" or
        player.Name == "Nick7cool" or
        player.Name == "DarwinYork" or
        player:IsInGroup(1107429) or
        game:GetService('GamePassService'):UserHasGamePass(player.userId, 285082790) or
        game.CreatorId == player.userId
    )
    if allow then
        open()
        delay(4.5, close)
    end
end)

more specifically

game: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 8 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:

AllowedPlayers={"SimplyKol",  "play1885", "Nick7cool","DarwinYork"}

function CorrectPlayer(player)
    for i,v in pairs (AllowedPlayers) do
        if player.Name==v then
            return true
        end
    end
    return false
end

    if CorrectPlayer(player) or  game:GetService('TShirtService'):UserHasTShirt(player.userId, 283727664) or game.CreatorId == player.userId then
        open()
        delay(4.5, close)
    end
end)

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 — 8y
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 — 8y
Ad

Answer this question