youll need to communicate to the client and returns back the client’s mouse position
you can use remote functions to do that
--[[-------------------------------------------------------------------------------------------
SERVER SCRIPT
---------------------------------------------------------------------------------------------]]
local RequestFromClient = game.ReplicatedStorage.RemoteFunction -- remote function
RequestFromClient.OnServerInvoke = function(Player, MouseX, MouseY )
-- the request
print(Player.Name, "Mouse X position is", tostring(MouseX), "And Mouse Y position is", tostring(MouseY))
end
-- example request the client to get its mouse position
game.Players.PlayerAdded:Connect(function(Player)
repeat
pcall(function()
RequestFromClient:InvokeClient(Player)
end)
task.wait(1.5)
until
Player == nil
end)
--[[-------------------------------------------------------------------------------------------
LOCAL SCRIPT
---------------------------------------------------------------------------------------------]]
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local RequestFromClient = game.ReplicatedStorage:WaitForChild("RemoteFunction") -- remote function
RequestFromClient.OnClientInvoke = function()
RequestFromClient:InvokeServer(Mouse.X, Mouse.Y)
end