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

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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.

0
so what would i use to get the player because i cant have it in a local scriptt cjkizzy286 40 — 3y
0
You can send the mouse variable to a server script using a remote event. User#32819 0 — 3y
0
and how would i do that cjkizzy286 40 — 3y
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() User#32819 0 — 3y
View all comments (4 more)
0
i know what they are but im trying to make the roblox arm face the mouse cjkizzy286 40 — 3y
0
but in what u said i understood but the argument bit cjkizzy286 40 — 3y
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. User#32819 0 — 3y
0
okay cjkizzy286 40 — 3y
Ad

Answer this question