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?
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! :)