Im trying to get player's mouse position. But im getting ServerScriptService.DamagableManager:48: attempt to index local 'mouse' (a nil value) error
LocalScript that im trying to connect to Server Script:
local function onMousedClicked(actionName,inputState, inputObject) if inputState == Enum.UserInputState.Begin then CheckIfDamagable:InvokeServer() print("MouseClicked") end end
server Script that im tring to get mouse info:
function CheckIfDamagableObject(player) local mouse = player:GetMouse() --Unrelated codes here end CheckIfDamagable.OnServerInvoke = CheckIfDamagableObject
You cannot get mouse info from a non-local script.
I can't think of a reason that you would want to do anything with a player's mouse from a non-local script either; if you want to damage something (judging by the name of your script) then you should instead have the function send the amount of damage to deal to the object and then have the serverscript deal the damage, so it doesn't have to deal with the client's mouse.
Good luck with your game!