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

Why my LocalScript do not find my ModuleScript in ServerStorage?

Asked by 7 years ago
Edited 7 years ago

Okkey, I put this code:

local PlayerStatManager = require(game.ServerStorage.PlayerStatManager)

I get this error:

ServerStorage is not a valid member of DataModel

I put this code:

local PlayerStatManager = require(game:GetService('ServerStorage').PlayerStatManager)

I get this error:

PlayerStatManager is not a valid member of ServerStorage

How to do it ?

1
Use code blocks. hiimgoodpack 2009 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago

If you want to make a LocalScript to access the ServerStorage and access ModuleScript then

--Inside of a script, place the script inside ServerScriptService, Rename the script "FuncAdder"
local bindablefunc = Instance.new("RemoteFunction")
bindablefunc.Name = AccessModuleScript
local folder = Instance.new("Folder")
folder.Name = "AccessServer"
folder.Parent = workspace
bindablefunc.Parent = folder
--Inside a LocalScript
--Script and events all that stuff
--When you want too use require, replace with this
local Func = workspace.AccessServer:WaitForChild("AccessModuleScript")
local playerstats = Func:FireServer()
--Do whatever with playerstats
--Inside of ServerScriptService again, Rename this to "RequireInfo"
local func=workspace.AccessServer:WaitForChild("AccessModuleScript")
func.OnServerEvent:connect(function()
    local PlayerStatManager = require(game.ServerStorage.PlayerStatManager)
    return PlayerStatManager
end

If you have trouble, contact me. How? Idk, also, i haven't tried the script yet

0
Now how I use the ModuleScript in my LocalScript? NiniBlackJackQc 1562 — 7y
0
FireServer and OnServerEvent is utilised for RemoteEvent and not for RemoteFunction and same if I fix your code, I get this error: OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available NiniBlackJackQc 1562 — 7y
0
Ok is good I have everything fix, thanks NiniBlackJackQc 1562 — 7y
Ad
Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

LocalScripts cannot access ServerStorage. Instead, use ReplicatedStorage. Also, if you don't already know, scripts cannot run in ServerStorage nor ReplicatedStorage.

0
Accept my answer if this works for you. hiimgoodpack 2009 — 7y
0
Error: DataStore can't be accessed from client NiniBlackJackQc 1562 — 7y
0
And: Requested module experienced an error while loading NiniBlackJackQc 1562 — 7y

Answer this question