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
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
And also your if statement has problem, you don’t put extra ifs after andor
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
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