How can I require the MainModule from ServerScriptService in a LocalScript? (DataStore2)

I’m trying to create a simple GUI that adds one point per click to the player’s stats. However, the LocalScript isn’t able to require() from ServerScriptService because it’s client-side only. Also, is it even possible to require() DataStore2 from a LocalScript? I’ve never worked with DataStore2 before so this is all new ground to me.

local DataStore2 = require(game.ServerScriptService.StatsDataStore2:WaitForChild("MainModule"))
local Player = game.Players.LocalPlayer

function onclick()

		local PointsStore = DataStore2("Points", Player)


1 Like

Use a RemoteEvent:

The client can’t access ServerScriptService, so it’s better to put client sided modules in ReplicatedStorage.

And DataStore2 should be used on the server, not the client.

You cannot require module scripts locally which are in areas that the local player cannot access. Try using ReplicatedStorage instead.

Don’t know anything about DataStore2 but I’d assume you can’t use it locally anyway.

you cant give points from the client with or without DataStore2 because in the server it will remain as unchanged and i suggest you to use events to give stats.If u use clients for DataStore2 hackers can change their stats easily and save them too.

1 Like