So I have a bunch of functions and when all the function are done I fire a bindable event to tell the other scripts that the data has been loaded on the server, but the script never gets to that part for some reason.
I just have a bunch of functions and then it doesnt fire and the printing also doesn’t work before the event:
local getData = serverData:GetAsync(game.PrivateServerOwnerId) -- maybe change to PrivateServerId instead of PrivateServerOwnerId
local function getUpgradeData(currentUpgradeFolder)
for i,v in currentUpgradeFolder:GetChildren() do
local folderModule = string.gsub(currentUpgradeFolder.Name,"UpgradesFolder","").."Upgrades"
if upgradeModule[folderModule][v.Name].Hidden then
if upgradeModule[folderModule][v.Name].Hidden == true then
v.Parent = upgradesHiddenFolder
end
end
end
end
if not getData then
getUpgradeData(upgradesFolder)
getUpgradeData(goldenUpgradesFolder)
end
local function spawnUpgrades(newUpgradesFolder,color)
print(string.gsub(newUpgradesFolder.Name,"UpgradesFolder","").."Upgrades")
for i,v in upgradeModule[string.gsub(newUpgradesFolder.Name,"UpgradesFolder","").."Upgrades"] do
print("EE")
if not getData[v.Name] and not getData[v.Before] and v.Hidden == true then
newUpgradesFolder:FindFirstChild(v.Name).Parent = upgradesHiddenFolder
elseif getData[v.Name] then
local currentUpgrade = newUpgradesFolder:FindFirstChild(v.Name)
currentUpgrade.Owned.Value = true
currentUpgrade.SurfaceGui.Price.Text = "Owned"
currentUpgrade.SurfaceGui.Info.Text = v.Info
currentUpgrade.Color = color
if upgradeModule.UpgradesFunctions[currentUpgrade.Name] then
upgradeModule.UpgradesFunctions[currentUpgrade.Name]()
end
end
end
end
if getData then
for i,v in statsFolder:GetChildren() do
if getData[v.Name] then
v.Value = getData[v.Name]
end
end
spawnUpgrades(upgradesFolder,Color3.fromRGB(110, 110, 112))
spawnUpgrades(goldenUpgradesFolder,Color3.fromRGB(113, 90, 0))
end
print("FIRED")
dataLoaded:Fire()
Try adding some warnings into your script. Something like so:
local getData = serverData:GetAsync(game.PrivateServerOwnerId) -- maybe change to PrivateServerId instead of PrivateServerOwnerId
local function getUpgradeData(currentUpgradeFolder)
for i,v in currentUpgradeFolder:GetChildren() do
local folderModule = string.gsub(currentUpgradeFolder.Name,"UpgradesFolder","").."Upgrades"
if folderModule then
if upgradeModule[folderModule][v.Name].Hidden then
if upgradeModule[folderModule][v.Name].Hidden == true then
v.Parent = upgradesHiddenFolder
print("Moved", v.Name)
end
else
warn("Hidden not found in", currentUpgradeFolder)
end
else
warn("FolderModule not found in", currentUpgradeFolder)
end
end
end
if not getData then
warn("Requesting Data")
getUpgradeData(upgradesFolder)
getUpgradeData(goldenUpgradesFolder)
end
local function spawnUpgrades(newUpgradesFolder,color)
print(string.gsub(newUpgradesFolder.Name,"UpgradesFolder","").."Upgrades")
for i,v in upgradeModule[string.gsub(newUpgradesFolder.Name,"UpgradesFolder","").."Upgrades"] do
print("EE")
if not getData[v.Name] and not getData[v.Before] and v.Hidden == true then
newUpgradesFolder:FindFirstChild(v.Name).Parent = upgradesHiddenFolder
elseif getData[v.Name] then
local currentUpgrade = newUpgradesFolder:FindFirstChild(v.Name)
currentUpgrade.Owned.Value = true
currentUpgrade.SurfaceGui.Price.Text = "Owned"
currentUpgrade.SurfaceGui.Info.Text = v.Info
currentUpgrade.Color = color
if upgradeModule.UpgradesFunctions[currentUpgrade.Name] then
upgradeModule.UpgradesFunctions[currentUpgrade.Name]()
end
end
end
end
if getData then
for i,v in statsFolder:GetChildren() do
if getData[v.Name] then
v.Value = getData[v.Name]
end
end
spawnUpgrades(upgradesFolder,Color3.fromRGB(110, 110, 112))
spawnUpgrades(goldenUpgradesFolder,Color3.fromRGB(113, 90, 0))
else
warn("No Data")
end
print("FIRED")
dataLoaded:Fire()