Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Im trying to get the mouse target and it has a error?

i keep getting a error when i try to get the mouse

local player = game.Players.LocalPlayer
local mouse = player:GetMouse() -- the error is here

the error message is : 17:45:02.409 - Workspace.Script:2: attempt to index nil with 'GetMouse'

1 answer

You can't find LocalPlayer in a normal script, thus you can't get :GetMouse(). You can only do it on local scripts. You should also know that local scripts can't run in workspace.

8 comments

0

so what would i use to get the player because i cant have it in a local scriptt

0

You can send the mouse variable to a server script using a remote event.

0

and how would i do that

0

https://developer.roblox.com/en-us/api-reference/class/RemoteEvent this page has info on remote event's, you can also watch a tutorial on it, but basically what you want to do is send the "mouse" variable in the localscript in the argument in :FireServer()

0

i know what they are but im trying to make the roblox arm face the mouse

0

but in what u said i understood but the argument bit

0

In .OnServerEvent you can get the mouse variable and do your script normally. About the arm facing the mouse, I can only tell you to use CFrames. After you made a script and if it doesn't work, you can make a question and we'll fix it for you.

0

okay

This discussion is preserved as it was. New answers, comments, and votes are closed.