Alright, I've done a script that makes me know my cursor coordinates. What if I want to teleport there? I tried to do something like this, but it's not working.
local m = game.Players.LocalPlayer:GetMouse() local character = game.Players.LocalPlayer.Character local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local MouseCFrame = Mouse.Hit local MousePosition = MouseCFrame.p local db = true local secondtime = false m.KeyDown:connect(function(k) k = k:lower() if k == 'x' then game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(MousePosition)) end end)
Help please.
You can raycast using the player's mouse's position - Camera.ScreenPointToRay
A more simpler way of doing this,however is using Mouse.Hit
target = game.Players.LocalPlayer:GetMouse() .Hit x = target.X y = target.Y z = target.Z game.Players.LocalPlayer.Character:MoveTo(Vector3.new(x,y,z))
This can work fine, but I would recommend the ScreenPointToRay.