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

Why wont this script find a ModuleScript named shop?

Asked by
epoke466 100
2 years ago

Im confused.

There is a module script in server script service. Its name is shop.

My (local) script:

local ServerScriptService = game:GetService("ServerScriptService")
local Module = require(ServerScriptService.Shop) --The problem.

function onClick()
    Module:PurchaseAnthem(game.Players.LocalPlayer, script.Parent.Parent.Id.Value, script.Parent.Parent.Price.Value)
end

script.Parent.MouseButton1Click:Connect(onClick)

When I try to get the module it doesn't work and I get an error in the output: "Shop is not a valid member of ServerScriptService "ServerScriptService"

1
LocalScript(Client) cannot access the Server. These services are ServerScriptService and ServerStorage. The best place to store modules is ReplicatedStorage. Client and Server can access this service. MarkedTomato 810 — 2y
0
Ty epoke466 100 — 2y

1 answer

Log in to vote
2
Answered by 2 years ago

This is because its in ServerScriptStorage. As soon as the game is run, anything inside there gets sent somewhere else. You can use ReplicatedStorage instead, it works that way.

0
ty epoke466 100 — 2y
Ad

Answer this question