In a module script called “ObjectDataManager” I have information about tools and objects in my game that I can just look up from the module script.
It looks like this:
local DataStore = {}
DataStore.Gems = {
{Name = "Diamond", Color = Color3.new(0.32, 0.76, 0.65), Value = 1000, Hardness = 10, SizeMultiplier = 1.2},
{...},
}
DataStore.Pickaxes = {
{Name = "RustyPickaxe", Value = 10, Hardness = 1},
{...}
}
function DataStore:GetPickaxes()
local Pickaxes = {}
for _, pickData in pairs(self.Pickaxes) do
Pickaxes[pickData.Name] = pickData
end
return Pickaxes
end
function DataStore:GetGems()
local Gems = {}
for _, gemData in pairs(self.Gems) do
Gems[gemData.Name] = gemData
end
return Gems
end
return DataStore
Then, within ReplicatedStorage, I have module scripts that will call upon the ObjectDataManager in order to organize and grab the information, for example:
-- Gem Module Script
-- Gather information about all gems in the game
local dataStore = require(game:GetService("ServerScriptService"):WaitForChild("ModuleScripts"):FindFirstChild("ObjectDataManager"))
local Gems = dataStore:GetGems() -- Load in all the gems
return Gems
The gem module script that grabs information for gems works perfectly fine. However, when I try implementing the exact same thing for Pickaxes (same code as the one above except replaced with “GetPickaxes()”, I get an “Infinite yield possible on 'ServerScriptService:WaitForChild(“ModuleScripts”)”.
Here’s the message log:
Infinite yield possible on ‘ServerScriptService:WaitForChild(“ModuleScripts”)’ - Studio
Stack Begin - Studio
Script ‘ReplicatedStorage.ModuleScripts.HitManager’, Line 5
I’ve tried to look for solutions already on here that are similar but I haven’t found any. Any advice or suggestions would be appreciated! Thank you.