#TeleportService
1 messages · Page 1 of 1 (latest)
i believe you need to use TeleportService, and a LocalScript to get the player trying to teleport
like, i think i need to somehow get service mouse click am i right?
and then i dont have any ideia to how can i make the teleport
no need for userinputservice when u have a button, you can just wire the mouse1 click event that the button has built-in to your own function
you'd get the service with a local ts = game:GetService("TeleportService")
** You are now Level 1! **
and then also get the player with the same method, getservice players
i can add the event on the button ?
and a local script
then event teleport in the server script storage?
you can say script.Parent for the button 😛
and no need for the event, the event we will use is pre-coded in the button
so youd say local SPB = script.Parent
the script will refer to the script itself, and this way we would path to the script's parent (which is the button)
hmm
youll have to refer to the player thats pressing the button first, and then put all of this under a function
so youd do local player (or anything u want) = Players.LocalPlayer
no need for 2 line?
i mean you can use it
hmm so nice so far, the roblox creator hub tells us to use the new :TeleportAsync() instead of that
** You are now Level 2! **
in that function, the first thing is the placeId
second is p (the player that will press the button)
and third is the private server code
just the server code
lemme try
** You are now Level 4! **
isnt working
😦
so now we have the line of code thatll work when we click right
we need to make the button clicking call this code
something similar, but you dont need to get a service for it
it comes with the button
so its SPB right
youd say SPB.MouseButton1Click
and this will make the script listen for someone pressing the button with a left click
once it detects u click the button, it will activate the line
and we can make it activate the server joining code we just wrote
so to translate this, once the button is clicked with mouse1, it connects to the function
hmmm
so in my playtesting it says that the teleportservice can only be called by the server
and since this is a local script, meaning it runs on the client, it cant call it
lemme try something rq
hmm
understanding
alr
so i came up with a solution that i think will work
heres the full setup that i came up with
we have a script in sss, so that the server handles the teleporting process (since its a roblox requirement apparently)
** You are now Level 3! **
i forgot to tell u which script is which :P
the first one is the teleporterscript
second is the script inside the button
if theres anything stuck on ur mind i can explain
its a place where things that are inside of it are replicated to both the server and the client
so if u have a script working on the client only, you can access it
which is how we were able to use the event in both a local script and a normal script
fireclient makes it so that the event we made fires to a client, and in the brackets we put in any data we wanna transmit
teleportasync is like the fancy new version of the teleport command
i dont got it
hmmm so with an event u have 2 variants
one is bindable which is server to server, and client to client communication
the one we use is a remote event, which allows for server - client communication
when we call this in our local script (which is the client), the data that we put inside the event is there now
later, in the teleporter script in serverscriptservice (which is the server), we can access it by saying onserverevent and get the data that was in that event
im not too good with words so ill try to illustrate it
if there are still questions on ur mind, there's a channel on youtube called "BrawlDev" that explains stuff like these in an interactive way
i can't focus on anything that doesnt have 4 screens of subway surfers gameplay on it, and i learnt this from him
thankyou so much bro
i have the same issue XD
1- local
2- script
isnt working btw
is the Fire Client
in the local script
maybe it needs to be on the SSS
?
@elder trout
yo whats the problem
well yeah 😭
what are u tryna do get someone to tp to a game?
y
** You are now Level 5! **
a lobby system?
and i need this teleport
no
Ohhh
its more like a text button that teleport
oh so its not a part but a button 😭
a button u press that tps you to the game, with the option of playing single player and multiplayer?
yess
i can send you the lobby
here is it
Lol i cant do nth with that without perms but i dont need it
what i do need
is the script that controls the tp
just to see the menu
i will send you
wtv handles the behavior
local SPB = script.Parent
local SPBEVENT = game:GetService("ReplicatedStorage").TeleporterEven
local p = game:GetService("Players").LocalPlayer
SPB.MouseButton1Click:Connect(function(p)
SPBEVENT:FireClient(p)
end)
local tp = game:GetService("TeleportService")
local placeId = 14390772826
local code = tp:ReserveServer(placeId)
local SPBEVENT = game:GetService("ReplicatedStorage").TeleporterEvent
SPBEVENT.OnServerEvent:Connect(function(p)
tp:TeleportAsync(placeId, p, code)
end)
1- local
2-script
and u DO have a sss script to handle that right
yes
sned that over too
sss script is number too
oh wait
ooh
alright also send a ss of the hierachy
for the button that tps player
so ik what its parented to
alr just a min
aigh
alr thanks
so errors in local script
1 using FireClient in LocalScript
2 parameter in MouseButton1Click
3 typo in RemoteEvent name
errors in sss
1 incorrect TeleportAsync use
2 reserving Server too early
3 event name mismatch
lowkey its mad easy to fix
wym parameter?
ah in the MouseButton1Click function u have function(p)
how can i use corectly?
and fire client too
fire client should be server not client
local sciprt has the easiest fixes so
local SPB = script.Parent
local SPBEVENT = game:GetService("ReplicatedStorage").TeleporterEvent
local p = game:GetService("Players").LocalPlayer
SPB.MouseButton1Click:Connect(function()
SPBEVENT:FireServer()
end)
event name is teleporter Event
Oops might need to change that to fireserver
name dont mismatch more
local tp = game:GetService("TeleportService")
local placeId = 14390772826
local code = tp:ReserveServer(placeId)
local SSSSPBEVENT = game:GetService("ReplicatedStorage").TeleporterEvent
SSSSPBEVENT.OnServerEvent:Connect(function(p)
tp:TeleportAsync(placeId, p, code)
end)
how can i use corectly the tp async?

