local PassId = 162973845
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, PassId) then
wait()
script.Parent.Glass.Anchored=false
script.Parent.Glass.Velocity=Vector3.new(0,0,50)
script.Parent.Parent.CoverRemoved.Value=true
script:Destroy()
end
end)
Hey, there is an issue with your code where the wait() function is blocking the code from executing the remaining lines of code. Instead of using the wait() function, you can use the Debris:AddItem() method to destroy the part after a certain delay. Here’s an updated version:
local PassId = 162973845
local ClickDetector = script.Parent.ClickDetector
local Glass = script.Parent.Glass
local CoverRemoved = script.Parent.Parent.CoverRemoved
ClickDetector.MouseClick:Connect(function(plr)
if game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(plr.UserId, PassId) then
Glass.Anchored = false
Glass.Velocity = Vector3.new(0, 0, 50)
CoverRemoved.Value = true
– Destroy the part after 1 second
game:GetService(“Debris”):AddItem(script.Parent, 1)
end
end)