local gamepass = 5620181
local service = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:connect(function()
if service:PlayerOwnsAsset(gamepass) then
if script.Parent.Parent.Parent.TeleportGui.Enabled == false then
script.Parent.Parent.Parent.TeleportGui.Enabled = true
else
script.Parent.Parent.Parent.TeleportGui.Enabled = false
end
end
end)
It's supposed to open a gui if the player owns the gamepass.
EDIT: Figured out that a few things had been changed. There's now no error whatsoever, but nothing happens when clicking the button
Here's the new script:
local passid = 5620181
local service = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:connect(function()
if service:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, passid) then
if script.Parent.Parent.Parent.TeleportGui.Enabled == false then
script.Parent.Parent.Parent.TeleportGui.Enabled = true
else
script.Parent.Parent.Parent.TeleportGui.Enabled = false
end
end
end)

3 comments
Hmm... I don't get the error anymore, but now nothing happens.
Try changing the fourth line with " if service:PlayerOwnsAsset(game.Players.LocalPlayer.UserId,gamepass) then " or
or this if service:PlayerOwnsAsset(game.Players.LocalPlayer,gamepass) == true then