Whitelist script wont open a door for my character

In this script I am trying to turn CanColide to false if the player owns a gamepass or is a certain playerId. The issue I’ve been finding is that it keeps saying " Expected ‘else’ when parsing if then else expression, got ‘print’" and I have no idea why. I’ve gone through my script and I think the problem has to do with the “or” but what I did seems right. Any help is appreciated

local player = game.Players.LocalPlayer
local GamePassId = 6766156 -- Replace with your gamepass
local WhitelistUserIDs = {79523404, 465747981 }

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamePassId) == true or if not table.find(WhitelistUserIDs,player.UserId) then
	game.Workspace.GamepassDoor.CanCollide == false
	print("hehg") 

end	

thanks for the help in advance

1 Like

Well, you first have to put 1 = between Cancollide and false in line 6.

1 Like

Hey Synthx,

After reading your code i found a way to make it work.

Try code below:


local GamePassId = 6766156

local WhitelistUserIDs = {79523404, 465747981}

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, GamePassId) or if table.find(WhitelistUserIDs,Player.UserId) then

game.Workspace.GamepassDoor.CanCollide = false

end

Let me know if it worked! :smiley:

1 Like

Thsi should be

game.Workspace.GamepassDoor.CanCollide = false

== is used with comparing, assigning uses =

And also your if statement has problem, you don’t put extra ifs after and or

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamePassId) == true or if not table.find(WhitelistUserIDs,player.UserId) then

Should be

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamePassId) == true or not table.find(WhitelistUserIDs,player.UserId) then
4 Likes

Hmm it still says the same error code :c

Can you tell me whats the error?

1 Like

This did work! but I am not encountering a new issue somehow, now it prints “hehg” even if I dont touch it?

It work now but it prints “hehg” even if I dont touch it which is a problem

If you want to make it work when you touch it, you have to use the Touched event

https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched

Though if you are going to use the Touched event, then you can make this a regular script than a local one since you can easily get the player because Touched returns the Part that touched the door in your case

1 Like

yeah sorry I forgot to add that to my code, I had changed it around so much SORRY

1 Like

A comment to the thread’s poster, this table is an example of a blacklist not a whitelist.

Yeah I forgot about the “if not” thanks