Is there a way to constantly check for a player's mouse position (mouse.Hit.p) and utilize it within a non-local script? I have tried numerous different things, none of which seem to be working. Do I need to use remote functions or is there an easier way?
Remote Functions is the way the to go,you could send mouse.Hit.p through the remote in a global script and use it on from there as a variable
Example:
Local Script
local Player = game.Players.LocalPlayer local mouse = Player:GetMouse() game.ReplicatedStorage.RemoteEvent:FireServer(mouse.Hit.p)
Server Script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,position) -- The "position" variable is the mouse.Hit.p that you have sent through the RemoteEvent , now you can use it in any way, for example print(position) end)
Yea, the best way to pass the mouse target to the server would be remote events. I'm not really sure what you're trying to achieve with this but their are likely better ways to do this that don't involve giving the server the mouse target.
Nevertheless, here's how you would go about that.
Localscript:
local mouse = game:GetService("Players").LocalPlayer:GetMouse() mouse:GetPropertyChangedSignal("Target"):Connect(function() MouseTargetEvent:FireServer(mouse.Hit.p) end)
Server script:
MouseTargetEvent.OnServerEvent:Connect(MouseTargetChangedFunction)
If you feel my answer solved your problem and was the best please remember to accept it!