Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

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

Asked by 4 months 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
zamd157 1109 Moderation Voter
4 months 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 24 — 4mo
0
You can send the mouse variable to a server script using a remote event. zamd157 1109 — 4mo
0
and how would i do that cjkizzy286 24 — 4mo
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() zamd157 1109 — 4mo
View all comments (4 more)
0
i know what they are but im trying to make the roblox arm face the mouse cjkizzy286 24 — 4mo
0
but in what u said i understood but the argument bit cjkizzy286 24 — 4mo
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. zamd157 1109 — 4mo
0
okay cjkizzy286 24 — 4mo
Ad

Answer this question