Roblox Mouse Click to TP in another place not working

Hello cool peoples, so basically i am making a script to teleport the player to another place

       local TeleportService = game:GetService("TeleportService")

       function TP(plr)
      local server = TeleportService:ReserveServer(6310816848)
     TeleportService:TeleportToPrivateServer(6310816848,server, plr)


I know that when doing it in roblox studio it wont work so i went up playing the game in the roblox client and looked up on the developer console and got this Error

Unable To cast Value to objects
Stack Begin
Script ‘Workspace.Lobby.Solo.ClickDetector.script’ , line 10 function TP
Stack End

Any help is appreciated

Is script.Parent a Button or a ClickDetector?

It’s a ClickDetector and only uses MouseClick()

Which is the line 10 in your script?

EDIT: It looks like you are sending just the player, what about you put it in an array?

TeleportService:TeleportToPrivateServer(6310816848,server, {plr})

1 Like

Very cool i appreciate your help :+1:

1 Like