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

Why does this localscript for a SurfaceGui only work in PlaySolo?

local TeleportService = game:GetService("TeleportService")
local id = 364386074
local button = game.Workspace.LocationHologram.Hologram.SurfaceGui.ImageButton

function onClicked()
        TeleportService:Teleport(id)
end

button.MouseButton1Click:connect(onClicked)

This LocalScript only seems to work in PlaySolo, and not the actual server. I figured it was because it wasn't supposed to be a LocalScript. So, I tried this script using a ServerScript and rerouted the button variable but it still didn't work. Does anyone know why?

3 comments

0

Are you using Filtering Enabled?

0

Make it a ServerScript.

0

No, I'm not using FilteringEnabled. And also, I've tried using a ServerScript as I said in the post. But it still didn't work.

1 answer

I believe this is quite easy to fix!

The TeleportService arguments contain a few arguments that you should include. (player is not required in LocalScript but you never know, it's always nice to include)

I believe your code should be:

local TeleportService = game:GetService("TeleportService")
local id = 364386074
local button = game.Workspace.LocationHologram.Hologram.SurfaceGui.ImageButton

function onClicked()
        TeleportService:Teleport(id, game.Players.LocalPlayer)
end

button.MouseButton1Click:connect(onClicked)


This is because you're not telling the server who you're actually teleporting (even in a local script). Sorry if this is incorrect, but from my knowledge of TeleportService, I believe this should solve your problem!

If this does not solve your problem then it is most likely an issue with your event. Attempt to change MouseButton1Click to MouseButton1Down

Hope this helped! :)

1 comment

0

Unfortunately, this did not resolve the issue. I changed the event and included the extra argument but nothing changed. Thanks for trying to help though!

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