Hello there, I am making code that will teleport a player to a certain coordinate in the map, but it's not working and the textbutton is saying "Please type a correct value." and I'm not sure what to do now. And by the way, the problem is that my character will not teleport.
Here is the code: (Changed)
local player = game.Players.LocalPlayer
local playergui = player.PlayerGui
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local XCoord = playergui.ScreenGui.X
local YCoord = playergui.ScreenGui.Y
local ZCoord = playergui.ScreenGui.Z
local Teleport = script.Parent
Teleport.MouseButton1Click:Connect(function()
if typeof(tonumber(XCoord.Text)) or typeof(tonumber(YCoord.Text)) or typeof(tonumber(ZCoord.Text)) ~= "number" then
script.Parent.Text = "Please type a correct value."
wait(2)
script.Parent.Text = ""
else
character:MoveTo(Vector3.new(XCoord.Text, YCoord.Text, ZCoord.Text))
end
end)
Any help would be appreciated!

2 comments
Yea that would work but the problem is that my character won't teleport.
Yes, I know that. I'm telling you that if you say Torso.Position instead of rootpart.Position, it might fix it.