Hello, I was wondering why whenever I teleport a player to the mouse’s current position, it’ll just teleport somewhere random. I’m fairly new to using this language so I don’t exactly know if I’m doing this entirely wrong.
I’ve tried using Mouse.X, Mouse.Y and it works, but the player won’t teleport it to where the player wants it to.
Script:
local Mouse = Player:GetMouse()
Player.Chatted:Connect(function(message)
if message == "Dimenso" then
Notification(PlayerGUI.Server.Notification, "Press E to teleport.")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
game.Players.LocalPlayer.Character:MoveTo(Vector3.new(Mouse.X, Mouse.Y))
print("position set")
end
end)
end
end)
Mouse.X and Mouse.Y are the position on your monitor, not the position in the world.
Search for posts about aiming a gun using a mouse and you can find information about how to convert mouse position on the screen to world space.