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

Place Teleportation Script Not working?

I tried making this script to teleport the player to a different place in the game: every time i press it it says invalid player to teleport (it says this in the output section) PLS HELP

local TeleoprtService = game:GetService("TeleportService")
local place = 6559431690
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	TeleoprtService:Teleport(place, player)
end)

1 answer

✓ Accepted answer

You're using a normal script instead of a local script here. You're not supposed to be using a normal script for reasons such as:

  • LocalPlayer does not exist in server scripts: local scripts are native to different devices that they run on. Local scripts run on each client (player's device) and on their device, the LocalPlayer property is assigned a reference to the player associated with the device. Server scripts run on a server, which is a computer for every server. They don't run on a client's device, thus they do not have a LocalPlayer

  • Gui manipulation with server scripts is generally discouraged if the player edits instances on their device which will not replicate to the server

You should be using a local script instead

3 comments

0

I fixed the error thankfully but when I press the button it still isnt doing anything. I am trying it from the actual game since you cant tp in roblox studio so I am unable to see any errors.

0

Press F9 to open the dev console or type "/console" in the chat. Essentially, it's an in-game output that shows both the logs of both the server and client. While you're at it, what is the parent of the script? Is it in a button that's in a screengui, or in a surfacegui on a part?

0

The button is a screengui and it is working now but when I teleport there a message pops up that says I do not have access to the place I am trying to teleport to, but it keeps me there anyways.

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