Requiring module from local player returns an error type

image
When you require a module script using the local player (as shown in the image),
type checking breaks and it returns an error type, the script still works, only the type checking and auto completion is broken.


(a video showing the bug, both of them point to the same script)

Reproduction Files:
RequiringModuleScriptOnLocalPlayerReturnsErrorType.rbxl (55.2 KB)

This happens 100% of the time, across all games, and all scripts.

Expected behavior

The type checking to work correctly and return the correct type and have auto complete working the same as if you were to require using script.Parent
image

This is expected because technically there isn’t anything called “PlayerScripts” in studio mode.

The same argument can be used for GUI, since there is no PlayerUI in studio, but unlike this, it works fine.

You should honestly never try to require a module in starterplayerscripts, just put it in replicated storage. Will work the exact same

Hi,

Thank you for checking in on this issue. It is a little bit unintuitive how this works and using PlayerScripts this way can lead to inconsistent behavior, for example if you place the script on the top into ReplicatedStorage, it will not run, because the script loading order will not let this script to load.

For more, see Client-server runtime | Documentation - Roblox Creator Hub

As far as Type Checking is concerned, it doesn’t know about the runtime specifics of Roblox, only whatever is currently available, so it will underline this.

We’re currently researching a more intuitive way of handling these and similar issues but there is not timeline on that yet. Ideally that would address this issue as well.

Thank you for understanding!