Teleporting Script Issue

Hey Developers! I am having trouble with a teleport script. It is a localscript, and it is a big script that I made, but I only copied the snippet that is important. If someone suggests a remote event of function, I don’t know how to do those so if you tell me that, could you help me do it.

	local players = game:GetService("Players")
		local player = players.LocalPlayer
		local TeleportService = game:GetService("TeleportService")
		local placeID_1 = 5658470854
		TeleportService:Teleport(placeID_1, player)

Thank you all for the help in the very near future!

1 Like

What was the error in console when attempting to teleport the player to that place? When I checked the ID I had insufficient permissions to play the game.

It was a private place that only I could join. Do I need to make it public? It didn’t even work for me but I’ll make it public for testing if I need to.

No, if you have permissions to join it then the teleport should be valid, I was just making sure.

1 Like

Correct, you need to use server scripts to do it, also try adding a wait to the script to confirm everything has loaded in correctly, otherwise it will throw an error.

How can I move it to a serverscript when I want it to happen after something that happens inside of that localscript? Is this where the complex enters the room…

Complex: Enters the room…

How is this part of the code activated? By a GUI button perhaps?

1 Like

No, it isn’t. It is when the text stops coming. There is text saying like, “No, Stop!” and the text disappears, and then you get teleported to the game.

Edit: Which all happens after you press a button.

Another Edit: But the teleport is not triggered by a button and is not supposed to be triggered by a button.

Ok after the part that says no stop, you fire a remote event, telling the server to teleport the player

1 Like

Sorry, Uhm, I might be sounding a bit basic here, but can you help me with doing this? :slight_smile:

Edit: I knew it would all come down to a remote event, but I don’t know how to do them.

In replicated storage, you create insert something called a remote event. On the client, you fire this event with “:FireServer()” . On the server side, you refer to this remoteEvent and using “.OnServerEvent:Connect(function())”
More information can be found at Bindable Events and Functions | Roblox Creator Documentation
Feel free to ask if you need any help

1 Like

Okay, so let’s say that I have the server script, how do I get the Local Player as it is not a local script.

(Thanks for the support!)

when the server receives the event, the first argument is automatically the player that fired the event. It is put there by the game, you do not have to put this as one of the arguments on the client side. Basically, if on the client you send 1 piece of information, the server will receive 2 pieces of information, one of which being what the client sent, one of which being the player that fired the event.

1 Like

I am like Very confused. I kind of need to go now but I will continue this a bit latter today.

Thank you so much for all of your support! :wink:

I will catch you on this thread or on a message later.


1 Like