I'm having trouble with place teleportation. Just to summarize what my problem exactly is; I'll start with the general area everything is in. I'm trying to get it so that when you press a TextButton on your screen, it will teleport you to a different server. And I've put a ScreenGUI in the StarterGUI folder, and inside that is a TextButton. I've tried multiple scripts I know; but it hasn't worked; for instance, getting TeleportService and doing something else. I forgot exactly what I did to be completely honest; but I hope that doesn't get in the way of anything. Any help?
Script: script.Parent.NewCharbutton.MouseButton1Click:connect(function() game:GetService('TeleportService'):Teleport(game.Players.LocalPlayer, [517540166]))
Gyazo of my folders: https://gyazo.com/e29b417fb46b64e965c3e380dd9b6407
Gyazos of the code itself: https://gyazo.com/ff71655143ab294f33872f4c431d33c8 https://gyazo.com/95a9fda8aba328e9eb8a8aed18f0226d
Here's the fixed code, with explanations:
local id = 517540166 -- simplifying, easier to change things without delving into the code local tp = game:service("TeleportService") -- optimization, so the script doesn't have index this more than one time local button = script.Parent:WaitForChild("NewCharbutton") -- optimization local p = game.Players.LocalPlayer -- optimization button.MouseButton1Click:connect(function() tp:Teleport(p, id) end) -- there was no end), which is needed
The gyazo link does not actually work, for whatever reason, it may just be my PC, as the image just doesn't seem to appear (the actual image element doesn't seem to exist).
You should learn to format your questions properly, especially links and code blocks (check out the icons on top of the box questions/answers are in).
Hope I helped!
~TDP