Any way to do this? I need this since it is involved in a gun. I'm new to filtering enabled and I don't know how to transfer the mouse from a local script properly as it would only make a mouse variable for the OnServerEvent function but, not the whole script.
I resorted to putting the main script into a server script. The only thing left that stops it from working is finding a way to get the mouse.
You can get the mouse's position using RemoteFunctions.
Server; Asking the client for the mouse position
local RemoteFunction = game.ReplicatedStorage:WaitForChild('RemoteFunction') local MousePos = RemoteFunction:InvokeClient(game.Players.Player1,"MousePosition") print(MousePos)
Client; Giving the server the mouse's position.
local RemoteFunction = game.ReplicatedStorage:WaitForChild('RemoteFunction') local player = game.Players.LocalPlayer local mouse = player:GetMouse() --This acts like a normal function, so it can "give" anything the server asks in return. function RemoteFunction.OnClientInvoke(Argument) if Argument == "MousePosition" then return mouse.Hit.p end end
The above script is just an example. If you're using a Tool to get the mouse's position, you can just put a ServerScript, LocalScript, and RemoteFunction inside the tool to make it easier.