So I have a door that when touched it will check if you have a game pass and if you do have the game pass it will open up, but won't close, and only opens I really don't know why it won't work.
----Script----
-----------------------------------------------------------------------------------------------
local MS = game:GetService("MarketplaceService")
local Gamepass = 0 -- The ID of the Gamepass. --- I have an ID placed in my game already.
local OpenTime = 10 -- The time the door is open for.
local OpenTrans = 1 -- The transparency of the door when it is open.
local CloseTrans = 1 -- The transparency of the door when it is closed.
local BuyGUI = true -- Set to false to stop the BuyGUI appearing.
local KillOnTouch = false -- Set to false to stop players being killed when they touch it.
local Whitelist = {
1 --ROBLOX
} -- USERID || People that can open the door without owning the badge.
-----------------------------------------------------------------------------------------------
local Door = script.Parent -- The door
-----------------------------------------------------------------------------------------------
function CheckWhitelist(v)
for i = 1, #Whitelist do
if v == Whitelist[i] then
return true
end
end
return false
end
Door.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if Gamepass <= 0 then return nil end
if MS:UserOwnsGamePassAsync(plr.UserId, Gamepass) or CheckWhitelist(plr.UserId) then
Door.CanCollide, Door.Transparency = false, OpenTrans
wait(OpenTime)
Door.CanCollide, Door.Transparency = true, CloseTrans
else
Door.CanCollide, Door.Transparency = true, CloseTrans
if BuyGUI == true then
MS:PromptGamePassPurchase(plr, Gamepass)
end
if KillOnTouch == true then
plr.Character.Humanoid.Health = 0
end
end
end
end)

2 comments
Try removing line 32
its the closing that won't work I forgot to add that.