I’m trying to make an easier way to teleport players to another game through a game hub UI.
Inside a frame I got multiple ImageButtons with each having an attribute named “gameID”
I wrote a client script to test if it’s teleporting them to the correct corresponding places, however it’s printing out that’s it’s teleporting the player to each 5 of the game’s IDs.
Here’s my script:
local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)local portal = script.Parent
local confirmframe = Players.LocalPlayer.PlayerGui:WaitForChild(“GameFrame”)
local id = portal:GetAttribute(“gameID”)local details = MarketplaceService:GetProductInfo(id)
portal.Image = “rbxassetid://” … details.IconImageAssetId
local function teleportPlayer(player, gameId)
print(“Teleporting”, player.Name, “to game ID”, gameId)
endlocal function onClick()
– Enable the GameFrame when the portal is clicked
confirmframe.Frame.Visible = true
endportal.MouseButton1Click:Connect(onClick)
local yesButton = confirmframe.Frame.Yes
local yesButtonClicked = false – Variable to track whether the ‘Yes’ button has been clickedyesButton.MouseButton1Click:Connect(function()
if Players.LocalPlayer and portal:GetAttribute(“gameID”) and not yesButtonClicked then
yesButtonClicked = true
teleportPlayer(Players.LocalPlayer, portal:GetAttribute(“gameID”))
end
end)