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

"attempt to index local" on game server but not in studio?

Asked by 7 years ago
Edited 7 years ago

Imgur Link

^ Above I have linked 3 photos. - The Output - Script #1 that errored - Script #2 that errored

I don't understand what I'm doing wrong can someone please help me understand?

1 answer

Log in to vote
1
Answered by
shayner32 478 Trusted Moderation Voter
7 years ago
Edited 7 years ago

LocalScripts vs Scripts

Both of the scripts are LocalScripts - and both of them attempt to access ServerScriptService.

ServerStorage & ServerScriptService are restricted purely to the server.

LocalScripts are executed on a client, therefor they are unable to access ServerScriptService, and hence the object inside you are attempting to reference.

In studio, the 'play' button gives LocalScripts the same permissions Scripts have, as your studio is acting as the server AND the client at the same time.

Solution - remove the object you are attempting to reference from ServerScriptService. (it is not advised to make the two LocalScripts into Scripts -- it is not good practice)

Ad

Answer this question