i'm trying to make a shouting sim esq game with some friends and due to my lack of proper knowledge of decent scripting i can't figure out how to get the module script to not return nil
(yes we are aware about the roblox audio purge we'll find a way around it)
the server script (event handler)
--// Variables local rs = game.ReplicatedStorage local ss = game.ServerStorage local sss = game.ServerScriptService local pointScript = require(rs.ModuleScripts.EpicPoints) --// Functions --// addPoints function local function addPoints(plr,points) local plrPoints = ss.Points:FindFirstChild(plr.Name) plrPoints.Value += points end --// Shout function local function shout(points,plr) addPoints(points,plr) end --// Shouted event rs.Events.Shouted.OnServerEvent:Connect(function(points,plr) shout(points,plr) end)
the startergui script (button stuff)
--// Variables local plr = game.Players.LocalPlayer local rs = game.ReplicatedStorage local ss = game.ServerStorage local sss = game.ServerScriptService local ui = script.Parent local shoutButton = ui.ShoutButton local shoutNumber = shoutButton.ShoutNumber local pointScript = game.ReplicatedStorage.ModuleScripts.EpicPoints local pointTable = require(pointScript) --// Main script --// Shout button clicked shoutButton.MouseButton1Click:Connect(function() local pointsToGet = pointTable[shoutNumber.Value] print(pointsToGet) rs.Events.Shouted:FireServer(pointsToGet,plr) end)
any help as to why this is happening is appreciated
btw the module script is nothing much, just 2 values in the table
You didn't make any call to ModuleScript for it to return. You need to call the Module's function, for example:
Module
local mod = {} function mod.Test() print("Test") end return mod
Server (or Client)
local mod = require(script.ModuleScript) mod.Test()
Output:
Test
I don't know what's the function to call your module, but with this, you should be able to debug it easily.
Try change the Value of Variable pointScript
in the 2nd script to rs:WaitForChild("ModuleScripts"):WaitForChild("EpicPoints")
local pointScript = rs:WaitForChild("ModuleScripts"):WaitForChild("EpicPoints")
Hope the answer helping you :)
(Or maybe just see that guy answer, might help you too!)
nevermind; i fixed it
the problem was the module script itself apparently, i moved the points table to a server script and it worked fine from there on
no clue why the module script was doing that, but atleast it works now. thanks for the suggestions!