Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Me type game Id to teleport people button dosen't work?

Asked by
jjjona1 -1
1 year ago
Edited 1 year ago

I don't know why it don't work

local GameIDType = game.StarterGui.ScreenGui.Frame.TextBox.Text

local TextButton = game.StarterGui.ScreenGui.Frame.TextButton

local TeleportService = game:GetService("TeleportService")

TextButton.MouseButton1Click:Connect(function(player)

TeleportService:Teleport(GameIDType, player)

end)

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago
local GameIDType = game.StarterGui.ScreenGui.Frame.TextBox
local gamevalue = Instance.new("NumberValue")
gamevalue.Parent = game.StarterGui.ScreenGui.Frame
gamevalue.Value = GameIDType.Text
local TextButton = game.StarterGui.ScreenGui.Frame.TextButton

local TeleportService = game:GetService("TeleportService")

TextButton.MouseButton1Click:Connect(function(player) 
TeleportService:Teleport(gamevalue, player)
end)

Hope this works!

Doesn't work because:

You can't have a propety that is a string or a number for some objects that in a variable. For example: "example.Value", Instead, Write "example", and at another line the example's variable to add ".Value"

Hope this helps for your future projects!

Ad

Answer this question