I'm trying to make a teleporter that teleports a player only if the own access to that game, and if they don't it will make a gui appear and it will prompt them to buy it. Here is the script I tried:
local gameID = 72339019
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local PlayerOwnsAsset = MarketplaceService.PlayerOwnsAsset
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local success, doesPlayerOwnAsset = pcall(PlayerOwnsAsset, MarketplaceService, plr, gameID)
if doesPlayerOwnAsset then
game:GetService("TeleportService"):Teleport(gameID, plr)
else
plr.CharacterAdded:Connect(function()
plr.PlayerGui.PutInStarterGui.Frame.Visible = true
end)
end
end)
If you see anything wrong please let me know, thanks.
