I have a module script in replicated storage, but I was wondering how I would require it from the client?
Thanks for any help
I have a module script in replicated storage, but I was wondering how I would require it from the client?
Thanks for any help
require(game.ReplicatedStorage.ModuleScript)
just use regular old require()
.
replied the wrong person
I tried this but the print statement is printing out {} so I’m guessing theres something wrong
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local donationGuiEvent = RS:FindFirstChild("DonationGuiEvent")
local IconModule = require(RS:WaitForChild("PlayerIcons"))
local player = Players.LocalPlayer
donationGuiEvent.OnClientEvent:Connect(function(losers, winners)
local playerThumbnails = IconModule:GetThumbnailList()
print(playerThumbnails)
Most likely something with your modulescript, not the localscript, as it does detect the modulescript, just returns a wrong value. (show that specific functions and we’ll help)
You can require ModuleScripts from anywhere.
Note: if you require it on the server and the client, you are actually requiring two separate copies of the Modulescript - one on the client, the other on the server. If you want the server and client to talk to each other, use RemoteEvents
That might be it I previously had this script on the server, and it worked perfectly, so I don’t think the issue is with how I coded the module script I think its a logic issue. So say I have required it in a server script, could I just pass the table of info in the remote event?
Yes, if you require the modulescript from a localscript, it’s going to behave like it’s a localscript, you are probably trying to get something that is only available on the server
If the ModuleScript has the table already filled, that’s not the issue
If the ModuleScript has an empty table and you fill it on the server, it is probably the issue
When I try pass the table I get the error message:
‘tables cannot be cyclic’
Show how you are trying to pass it thru
for i = #losers, 1, -1 do
donationGuiEvent:FireClient(losers[i], losers, winners, IconModule)
end
local IconModule = require(game:GetService("ReplicatedStorage"):WaitForChild("PlayerIcons"))
you can’t pass through the modulescript, you’d have to get the values first then pass through the values, not the modulescript itself.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.