Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When i try to use a textbutton to tp the player it says the teleport id is invalid?

here is the script that sets the id

local player = game.Players.LocalPlayer
local places = player.places
local id = script.Parent.Parent.TextBox.Text

function click()
	places.p11.Value = id
	script.Parent.Parent.Parent.Parent.Parent.MyGames.page1.game1.ImageLabel.Image = "http://www.roblox.com/Thumbs/Asset.ashx?format=png&width=420&height=230&assetId=" .. id
end
script.Parent.MouseButton1Click:Connect(click)

script that teleports you

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
 
local placeId = player.places.p11.Value

wait()

function click()
	TeleportService:Teleport(placeId, player)
end
script.Parent.MouseButton1Click:Connect(click)

2 answers

✓ Accepted answer

Try using tonumber on the Id:

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer

wait()

function click()
    TeleportService:Teleport(tonumber(player.places.p11.Value), player)
end
script.Parent.MouseButton1Click:Connect(click)

1 comment

1

well thats not the reason, when i press the button that sets the id it doesent change the value of p11

You are running the code local placeId = player.places.p11.Value before the player updates this value. The variable placeId will be the same each time.

You need to get the new value

script.Parent.MouseButton1Click:Connect(function()
	TeleportService:Teleport(player.places.p11.Value, player) 
end)

Hope this helps.

1 comment

0

or i could put the var. inside the function

This discussion is preserved as it was. New answers, comments, and votes are closed.