So I am trying to get this button to teleport the player to another game if they have ownership to the game, but if not, they will be prompted to purchase it. But it doesn't really seem to work; when I click the button, it does absolutely nothing.
Here is my script:
function hi(player) GameID = 199362426 game.Players.PlayerAdded:connect(function(player) game:GetService("TeleportService"):Teleport(GameID, player) end) local market=game:GetService("MarketplaceService") market:PromptPurchase(player,2016087191) end script.Parent.TextButton.MouseButton1Click:Connect(function()
Can somebody help me?
If you wish to verify that a given user owns an Asset, you can use MarketplaceServiceās :PlayerOwnsAsset()
method. This function returns a Boolean result, allowing us to build a conditional statement with this function to only run blocks of code if the ownership proves True. The function can also verify Paid Access places, so altogether, we can apply this in your Script.
local MarketplaceService = game:GetService("MarketplaceService") local PaidAccessAssetId = --// PlaceId of Paid Access Game. local Player = game:GetService("Players").LocalPlayer if (MarketplaceService:PlayerOwnsAsset(Player, PaidAccessAssetId) then --// Teleport else MarketplaceService:PromptPurchase(Player, PaidAccessAssetId) end
For the Teleport to work, you need to use an array of players. So you can just do {} on the player object to turn it into an array so Roblox can tp it.
function hi(player) GameID = 199362426 game.Players.PlayerAdded:connect(function(player) game:GetService("TeleportService"):Teleport(GameID, {player}) end) local market=game:GetService("MarketplaceService") market:PromptPurchase(player,2016087191) end script.Parent.TextButton.MouseButton1Click:Connect(function()