I'm trying to get the text from a textbox, and tp all invited players to a private server
But when I try to get the player, and I get this error:
Unable to cast value to object
--Local script in a textbutton
script.Parent.MouseButton1Click:Connect(function()
local pl = script.Parent.Parent.TextBox1.Text
local plr = game.Players:GetPlayerFromCharacter(pl)
game.ReplicatedStorage.ownerp4:FireServer(plr)
end)
--Script in workspace
game.ReplicatedStorage.ownerp4.OnServerEvent:Connect(function(n, plr)
print(plr)
local TS = game:GetService("TeleportService")
code = TS:ReserveServer(2097256710)
TS:TeleportToPlaceInstance(2097256710, code,{plr})
end)
I get my name in the console, but I don't get teleported to the server

3 comments
no, you misunderstand, Players:GetPlayerFromCharacter gets the PLAYER instance from the CHARACTER model, so something like game.Players:GetPlayerFromCharacter(game.Players.foo.Character) would return game.Players.foo
yeah, but if I use plr1 it still says that its an object
in both game.Players:FindFirstChild(pl) and game.Workspace:FindFirstChild(pl)