I typed this script to make a local part turn off can collide so that player can walk through the door. All of that code works, But the if statement doesn't work.

local MarketPlaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
print(player.UserId)

local cavePart = Instance.new("Part",game.Workspace)
cavePart.CanCollide = true
cavePart.Position = Vector3.new(91.13, 2, 7)
cavePart.Size = Vector3.new(1.75, 14, 14)
cavePart.Anchored = true
cavePart.Transparency = 0.5
cavePart.Name = "CavePart"

while wait(10) do
	print("Checking")
	if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, 8023068) then
		print(player.Name.." has the gamepass!")
		cavePart.CanCollide = false
		cavePart.BrickColor = BrickColor.new("Lime green")
		
	else
		cavePart.CanCollide = true
		cavePart.BrickColor = BrickColor.new("Persimmon")
	end
end

What did I do wrong?

2 comments

0

It doesnt look like u did anything wrong.

0

I know, but the cavePart just stays red. :/