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

Is it possible to make a universe teleporter script with a SurfaceGUI?

Asked by
Stravan 18
6 years ago

This is currently what I have right now

id = 364386074
TeleportService = game:GetService("TeleportService")
local holo = game.Workspace:FindFirstChild("Holo")


holo.SurfaceGui.ImageButton.MouseButton1Click:connect(function(plr)
    TeleportService:Teleport(id, plr)
end)

This does work in PlayTest, however, whenever I start up a server, it gives me the error that it attempted to index local holo (a nil value). This error doesn't really make sense to me, if someone can explain and help me make this script work that'd be great.

Also this is a LocalScript inside StarterPack.

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

The most likely problem is that the Holo part is not loaded in yet when the script first runs. To fix this, you can try using WaitForChild.

local id = 364386074
local TeleportService = game:GetService("TeleportService")
local holo = game.Workspace:WaitForChild("Holo")

holo.SurfaceGui.ImageButton.MouseButton1Click:connect(function(plr)
    TeleportService:Teleport(id, plr)
end)
0
That seems to have fixed that issue, but the actual teleport itself doesn't seem to work. The only thing it does is say "Teleport failed: Previous teleport is in processing" when I click a second time. I've waited for quite a bit, so I don't think it's doing anything. Stravan 18 — 6y
Ad

Answer this question