How can i get the mouse position on my screen?

I am trying to make ray from the origin of the mouse position on screen to the lookvector of the mouse, i do not know how to get the mouse position on screen, can someone help me?

local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local mouseX = mouse.X
local mouseY = mouse.Y
print(mouseX, mouseY)

https://developer.roblox.com/en-us/api-reference/property/Mouse/X
https://developer.roblox.com/en-us/api-reference/property/Mouse/Y

1 Like
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

print(mouse.Hit.Position)

on my screen, not the position where it hit

thank you so much it works it was simple!

Its , local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

print(mouse.Hit.Position)

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local X, Y = mouse.X, mouse.Y

Note: THIS SCRIPT HAS TO BE A LOCALSCRIPT