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)
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.
LocalScript is somewhere in StarterGui
The ScreenGUI is also in StarterGui local decal = game.Workspace:WaitForChild("Billboard"):FindFirstChild("GameImage")
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.