Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

mouse = player:GetMouse() nil value?

Asked by 4 years ago

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

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!

0
the problem is im trying to use ray casting method for it and because of that i need mouse position emay0660 13 — 4y
0
You can raycast on the localscript and then pass the necessary information from the raycast to the server GriffthouBiff 147 — 4y
Ad

Answer this question