I have a remote that will teleport a player to another player. Here is the script
script.Parent.OnServerEvent:Connect(function(_, tp1, tp2)
function shortenName(name)
local ReturnedName
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name:sub(1,name:len()):lower()== name:lower() then
ReturnedName = v.Name
end
end
return ReturnedName
end
tp1 = shortenName(tp1)
tp2 = shortenName(tp2)
workspace[tp1].HumanoidRootPart.Position = workspace[tp2].HumanoidRootPart.Position
end)
Here is my localscript
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Remotes.tp:FireServer(script.Parent.Parent.Parent.player.Text, game.Players.LocalPlayer.Name)
end)
The error: Players.7izr.PlayerGui.PlayerGui.gui.Remotes.tp.Script:13: bad argument #2 (string expected, got nil)
I have since fixed it. Its getting the list of children in game.Players but im trying to teleport a dummy that is not in game.Players

3 comments
I printed tp1 and tp2 and it print nil,7izr
You don't have to send the player parameter to the server script. It automatically picks up who the player is. Tp2 is not needed. I don't know what you're trying to do with the underscore as your first argument though.
the script isn't taking into account the possibility that one of the players may not exist