Teleporting a player from a localscript not working

I know this is probably easy, but this is my first time doing anything like this and I’m really just trying to learn the best I can. I made a script already but it’s not working and I’d like to know why.

local tService = game:GetService("TeleportService")

local teleportOptions = Instance.new('TeleportOptions')
teleportOptions.ServerInstanceId = game.JobId

game.ReplicatedStorage.Teleport.OnClientEvent:Connect(function()
	print("Message recieved")
	tService:TeleportAsync(game.PlaceId, {userid}, teleportOptions)
end)

The error is “Unable to cast value to Object” on the line I’m trying to teleport.

1 Like

Why not just teleport from a server script?
from the 8th line i assume you are using an user id, where the function takes a Player instead
and TeleportAsync is only usable on server

2 Likes

The same error is still happening.

1 Like

Using the player instead of the userid fixed it for me, still not sure why but whatever

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.