Player doesn't get teleported to game when pressing button in surface gui

player doesn’t get teleported to game when pressing button in surface gui,
script:

local btn = script.Parent
local gameInfo = game:GetService("MarketplaceService"):GetProductInfo(id)
local tps = game:GetService("TeleportService")
local decal = btn.Parent.Parent.Parent.AdPart:WaitForChild("GameImage")
local id = decal.Texture

btn.MouseButton1Click:Connect(function()
	tps:Teleport(id, game.Players.LocalPlayer)
end)
7 Likes

SurfaceGuis use ServerScripts if in workspace. You’ll need to do this from a ServerScript, or you can move the SurfaceGui to StarterGUI and set the .Adornee property to the part if you want to use a LocalScript.

1 Like

doesnt work
111111111111111111111111111

Which did you end up doing? (Char limit)

adornee to the surface gui’s parent

Did you change the definition of local decal? (Im assuming that’s in workspace, yes?)

no (char limit)
111111111111111111111111111

Is local decal, in workspace or in the actual gui. And is the localscript in startergui?

21

The surface Gui needs to be parented to StarterGui in order for a LocalScript to run it. LocalScripts run in PlayerScripts,PlayerGui,CharacterScripts

1 Like

still same thing
11111111111111111111111111

Are there any errors? Whatsoever?

1 Like

no, empty
11111111111111111111111111111

Checklist:

LocalScript is somewhere in StarterGui
The ScreenGUI is also in StarterGui
local decal = game.Workspace:WaitForChild("Billboard"):FindFirstChild("GameImage")

Oh and also send me the decal.Texture id.

If this script is run in a server script you can’t access LocalPlayer. You must get the player through server-sided methods.

e.g game.Players:GetPlayerByUserId

Most people can do this by having the user-input related systems in a local script, where the local script can run StartPlayerScripts, StarterCharacterScripts, StarterGui etc Then firing to a remote event to send the player to the place.

References:

the decal texture id is the game icon of the topic u answered earlier, any chosen game

Try to change the ID to the place ID and not the texture ID.

uhm what.
11111111111144444444

You set your id variable as a decal texture, not a game ID

im confused fr
1111111111111111111