Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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..."

2 comments

0

Thanks for the answer but I don't understand pairs or returning yet so I figured out the MarketPlaceService worked instead.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.