I created this script to make that roblox purchase screen appear for those who do not have a GamePass and DO NOT appear for those who have it. The problem is that this error is showing "Unable to cast value to Object, on line 21" and the screen sells does not appear.
local Gamepass1 = workspace.LEVEL2_MAP.GamePasstouch
local Id1 = 2544515
local debounce = false
Gamepass1.Touched:Connect(function(t)
if t.Parent:FindFirstChild('Humanoid') then
if debounce == false then
debounce = true
local haspass = false
local name = t.Parent.Name
local b = game.Players:FindFirstChild(name)
local success, message = pcall(function()
haspass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(b.UserId, Id1)
end)
if haspass == false then
print('stop')
game:GetService("MarketplaceService"):PromptGamePassPurchase(b.UserId, Id1)
elseif haspass == true then
print("go")
end
wait(0.5)
debounce = false
end
end
end)
