So I'm trying to make some type of Admin Panel, and in it a teleport to player button.
When I press it, I want my character to be teleported to a player using a TextBox, it doesn't work, but instead this happens:
"Argument 1 missing or nil". Also, it doesn't teleport. I don't know why it does so.
Script (Line 3 is long, so use View Source if needed):
script.Parent.MouseButton1Click:Connect(function() game.Players.LocalPlayer.Character:PivotTo(game.Workspace:FindFirstChild(game.StarterGui.ScreenGui.Frame.usrtlt.Text)) end)
Any answers appreciated!
This is a shot in the dark here as I can't really see how your game is organized, however I'm pretty sure that anything in the StarterGui
doesn't really have a position, as its purpose is only to clone everything in that folder to PlayerGui
. What may work is this:
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() -- you should also get in the habit of using these variables as they make your life a lot easier^ script.Parent.MouseButton1Click:Connect(function() char:PivotTo(game.Workspace:FindFirstChild(plr.PlayerGui.ScreenGui.Frame.usrtlt.Text)) end)
Let me know if this works as I'm genuinely curious lol