"Unable to cast value to Object" while trying to teleport?

Hey there! :wave:
I have never used TeleportService on roblox, so sorry if this is a rookie error! :tired_face:

Anyway, I’m getting an error that reads “Unable to cast value to Object”. I’ve never had this error before, so please help me out.

Here is the script I am currently using.

Code
local TeleportService = game:GetService("TeleportService")

game.Players.PlayerAdded:Connect(function(plr)
	if plr:IsInGroup(8342423) then
		if plr:GetRankInGroup(8342423) > 3 then
			local userId = plr.UserId
			local applicationCenterId = 6017993745

			TeleportService:Teleport(applicationCenterId,userId)
		else
			plr:Kick("An error occurred, try rejoining?")
		end
	else
		plr:Kick("Please join the group!\n\nhttps://www.roblox.com/groups/8342423/Moot-Theatre")
	end
end)

Thanks! :heart:

you teleport the player not UserId

1 Like