What am I doing wrong [Module scripts]

Hello!

While making my game, I made a gamepass and badge. Tl;DR, I’m making a letter and it changes wether you have the badge, gamepass or both. Text is different. So, in a local scripts in StarterGUI, my Output said there was an error over here:

local Check = require(game.ServerScriptService.GamePassBadge.CheckBadgeAndGamePass)

Am I doing anything wrong?

Thanks for reading!

Can you provide the code from the actual module script your using? Because a single require statement doesn’t say much, if anything. For all we know the module script you are requiring is empty and we would be none the wiser.

image

Module script:

local Check = {}

Check.OwnsGamepass = nil
Check.OwnsBadge = nil

return Check

I won’t be available soon, because I soon have online school. I can be available between breaks.

What did the Output exactly give for an error? It could be cause you’re making unnecessary table values nil

1 Like

This module script does absolutely nothing. It’s basically just storing two variables, which isn’t needed. You can instead use MarketplaceService | Roblox Creator Documentation for anything that relates to whether a player owns an asset or not.

1 Like

From here I assume you are trying to access the module script from a local script

and from here it says you are trying to access ServerScriptService (which is the server)

The client can never access the server hence not being able to access ServerScriptService, hence not be able to access the Module, hence erroring.

1 Like

Expanding off of what @elonrocket said, since you are using this in a local script then you shouldn’t be checking on the client, as that is terrible coding practice if the thing your checking is not strictly client-sided. Because of the Client-Server Model | Roblox Creator Documentation you can use a RemoteEvent | Roblox Creator Documentation to pass information from the server to the client.

If you want to check if the player owns a gamepass use MarketplaceService | Roblox Creator Documentation from a server script. If you want to check if they own a badge you can use BadgeService | Roblox Creator Documentation and BadgeService | Roblox Creator Documentation to track this.

1 Like

@BuilderBob25620 good point, there is a lot learn when it comes to client-server model and remote events because the client can change anything on the client, and fire anything through a remote event

That’s why you always need sanity checks on the server

good explanation by Autterfly
2 Likes

Thanks that was a dumb mistake of me to make the client interact with the server. I did use remote events but forgot to use them. That was dumb mistake of me.

1 Like

Basically in the module script, I have scripts for the badge and gamepass. And there’s other scripts that execute code based on the variables. Like I said before, it was dumb of me trying to have the client interact with the server.

1 Like

So what do you need then? I don’t understand what you are asking for now. If you need a way to see what the player owns I already answered that

Or are you having trouble with the data structure or data cacheing?

I am good, it was already working. Sorry if I badly worded my things.

I now know my mistake. A dumb stupid mistake.