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

attempt to index global 'Player' (a nil value)?

So i'm trying to use "mouse" to detect where a players mouse is hitting when they activate my tool and it keeps throwing the error (title)

the code here (line 4 is the error)

Tool=script.Parent
vCharacter = Tool.Parent
vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
mouse=vPlayer:GetMouse()

is it because i'm using a server script that i cannot get it?

2 comments

1

using tools is done by the player; so yes I'm thinking you should use a local script instead because the player is local and is using the tool, not the server

0

I made an edit to my answer, it should help you understand Remote Events a bit more.

1 answer

✓ Accepted answer

Statement

The tool is being used by the player which means it should be in a local script, try that and tell me how it runs.

Tools

How tools work is through the Client, when you make a change... you need to make sure that the client can make a change to the Server itself. To do this, you need to use a Remote Event which would be stored inside the tool itself. I don't know a lot about tools but I do know how Remote Events work so I am willing to help with any type of question revolving Remote Events. Here's a link describing how Remote Events and Remove Functions work. Also, if you're trying to get a change to happen on just the Client side then you just need a Local Script to do such a thing.

4 comments

0

ok ill try to use remote events

1

Alright, if you have issues with the Remote Events, make a new post and explain what the scripts do and what errors you're receiving.

1

If you are going to post an answer, please write it with explanations and code. What you have written is viable as a comment only

0

ima scrap remote events, just realized it just made things more complicated

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