I was trying to be neat placing a Module in ServerScriptStorage but I'm unable to require it from a Local Script so I made a RemoteFunction but I got an error.
How do I fix this error?
Error:
OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available
Players.Player.PlayerGui.LocalScript', Line 2
game.Workspace.Script:
RemoteFunction = Instance.new('RemoteFunction') RemoteFunction.Parent = script RemoteFunction.Name = 'GetShopModule' function RemoteFunction.OnServerInvoke() return game.ServerScriptService.ShopModule end
game.ServerScriptStorage.ShopModule:
Table = {} function Table.CreateShop() local Shop = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui) Shop.Name = "Shop" ------------------------------------------------------------- local body = Instance.new("Frame", Shop) body.ZIndex = 2 body.Size = UDim2.new(0, 680, 0, 389) body.BorderColor3 = Color3.new(0.94902, 0.94902, 0.94902) body.Name = "Body" body.Position = UDim2.new(0.5, -340, 0.5, -194) body.BackgroundColor3 = Color3.new(0.94902, 0.94902, 0.94902) ------------------------------------------------------------- local shadow = Instance.new("Frame", body) shadow.Active = true shadow.ZIndex = 3 shadow.BorderSizePixel = 0 shadow.Size = UDim2.new(0, 163, 0, 255) shadow.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843) shadow.Name = "Shadow" shadow.Position = UDim2.new(0, 0, 0, 136) shadow.Style = Enum.FrameStyle.DropShadow shadow.BackgroundColor3 = Color3.new(1, 1, 1) ------------------------------------------------------------- local title = Instance.new("TextLabel", body) title.FontSize = Enum.FontSize.Size48 title.TextWrapped = true title.ZIndex = 2 title.Size = UDim2.new(0, 238, 0, 78) title.TextColor3 = Color3.new(0.203922, 0.203922, 0.203922) title.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843) title.Text = "Catalog" title.Position = UDim2.new(0, 7, 0, 1) title.BackgroundTransparency = 1 title.Font = Enum.Font.ArialBold title.Name = "Title" title.TextXAlignment = Enum.TextXAlignment.Left title.TextStrokeColor3 = Color3.new(0.203922, 0.203922, 0.203922) title.TextScaled = true title.BackgroundColor3 = Color3.new(1, 1, 1) ------------------------------------------------------------- local body2 = Instance.new("ScrollingFrame", body) body2.ZIndex = 4 body2.Size = UDim2.new(0, 153, 0, 245) body2.ClipsDescendants = false body2.BorderColor3 = Color3.new(1, 1, 0.921569) body2.Name = "Body" body2.Position = UDim2.new(0, 1, 0, 140) body2.ScrollBarThickness = 6 body2.BackgroundColor3 = Color3.new(0.94902, 0.94902, 0.94902) ------------------------------------------------------------- local frame = Instance.new("TextLabel", body) frame.FontSize = Enum.FontSize.Size11 frame.TextWrapped = true frame.ZIndex = 4 frame.Size = UDim2.new(0, 156, 0, 58) frame.TextColor3 = Color3.new(1, 1, 1) frame.BorderColor3 = Color3.new(0, 0.635294, 1) frame.Text = "Category" frame.Position = UDim2.new(0, 0, 0, 78) frame.Name = "Frame" frame.TextStrokeColor3 = Color3.new(0.203922, 0.203922, 0.203922) frame.BackgroundColor3 = Color3.new(0, 0.635294, 1) ------------------------------------------------------------- local shadow2 = Instance.new("Frame", Shop) shadow2.Active = true shadow2.BorderSizePixel = 0 shadow2.Size = UDim2.new(0, 696, 0, 404) shadow2.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843) shadow2.Name = "Shadow" shadow2.Position = UDim2.new(0.5, -348, 0.5, -202) shadow2.Style = Enum.FrameStyle.DropShadow shadow2.BackgroundColor3 = Color3.new(1, 1, 1) end return Table
game.ScreenGui.LocalScript:
GetShopModule= game.Workspace.Script:WaitForChild('GetShopModule') ShopModule = require(GetShopModule.OnServerInvoke()) ShopModule.CreateShop()
What does the error mean and why did I get it?
How do I fix this and possibly make it more neater?
Oh and where could I place the script other then workspace?
(I can't place it in ServerScriptStorage because then I won't be able to invoke the function)
It is not possible to access any of the contents of ServerScriptService or ServerStorage from a LocalScript. This is by design.
Try putting the ModuleScript in ReplicatedStorage instead.