An error regarding getting a module script's tables to use in a gui

Hi DevForum! I ran into an error when trying to use a localscript to require a module script so I am able to use it in a gui.

Basically, what I am trying to make/edit is a scoreboard, but this one part of it is not working. It is automatically supposed to detect the home team and instantly put the team’s name and colors on the home section of the scoreboard gui, but again, that part is not working. For some reason, it works in the other game I have it in, but this one isn’t working.

TeamInfo has information about teams and their colors, etc. Here is a short piece from teaminfo:

local function Color(R,G,B)
  return Color3.new(R/255,G/255,B/255)
end
-- // {'Owners','ID:Rank'} \\ --
local Teams = {
  --[OFDL] Old Football Development League
  ['Lua Lions'] = {
    Logo = 2947056771;
    RGB = Color(151, 0, 0);
    RGB2 = Color(196, 40, 28);
    BC = BrickColor.new('Crimson');
    BC2 = BrickColor.new('Bright red');
    GroupID = 8342125;
    PlaceID = 6131002605;
    AdminRanks = {
    };
  };
}

Note: This script is a local script. GameValues is a configuration folder in replicatedstorage with a bunch of held values for the scoreboard. This line of code works in other games, but not this one. There are also already teams named after the one(s) in teaminfo.

Here is the script:

local Parent = script.Parent
local ABG = Parent.ABG
local HBG = Parent.HBG
local Underlay = Parent.Underlay
local ClockInfo = Parent.ClockInfo
local MainTime = ClockInfo.MainTime
local PC = ClockInfo.PC
local Down = ClockInfo.Down
local Time = MainTime.Time
local Quarter = MainTime.Quarter
local HScore = HBG.Score
local HTeam = HBG.Team
local AScore = ABG.Score
local ATeam = ABG.Team
local HP = Underlay.HP
local AP = Underlay.AP
local Flag = Parent.Flag
local Review = Parent.Review
local CountTime = 0
local Counting = false
local TeamInfo = require(game.ReplicatedStorage:WaitForChild('TeamInformation'))



for i, v in pairs(game.ReplicatedStorage.GameValues:GetChildren()) do
	if v.Name == 'Away' then
		if v.Value then
			local Last;
			for word in v.Value.Name:gmatch("%S+") do
				Last = word
			end
			ABG.Team.Text = string.upper(Last)
			if v.Value.Name ~= 'Away' then
				ABG.BackgroundColor3 = TeamInfo[v.Value.Name].RGB
			end
		end
	elseif v.Name == 'Home' then
		if v.Value then
			local Last;
			for word in v.Value.Name:gmatch("%S+") do
				Last = word
			end
			HBG.Team.Text = string.upper(Last)
			HBG.BackgroundColor3 = TeamInfo[v.Value.Name].RGB
		end
	end
end

or it can be this line thats causing the issue, or can be both:

for i, v in pairs(game.ReplicatedStorage:WaitForChild('GameValues'):GetChildren()) do
	v.Changed:Connect(function()
		if v.Name == 'Away' then
			if v.Value then
				local Last;
				for word in v.Value.Name:gmatch("%S+") do
					Last = word
				end
				ABG.Team.Text = string.upper(Last)
				if TeamInfo[v.Value.Name] then
					ABG.BackgroundColor3 = TeamInfo[v.Value.Name].RGB
				end
			end
		elseif v.Name == 'Home' then
			if v.Value then
				local Last;
				for word in v.Value.Name:gmatch("%S+") do
					Last = word
				end
				HBG.Team.Text = string.upper(Last)
				if TeamInfo[v.Value.Name] then
					HBG.BackgroundColor3 = TeamInfo[v.Value.Name].RGB
				end
			end
		end
	end)
end
1 Like

Are there any errors? Try placing a print statement into the ModuleScript to assure it’s actually being run.

There are actually no errors, I just checked everything over. I tested with a print statement too, but for some reason still nothing.

Yes, just put it before the for loop, like:

print("this is working...")

Thanks for the reply. I did that and it is working, but I found the issue, which it is only running when the value is changed for the second part of the script I was using.

For the first part, it only detects when the server is started if the home value,GameValues.Home , is already having a value which is the team. I figured out that another script manually changes the value to trigger the scoreboard to load the teaminfo data. Or it might be the same script, just not working in this certain game?

Would it still be possible to manually change the value with another script? Or is there a smarter way for going about it?

I’m confused on what you’re trying to achieve here. What value are you attempting to change?

So I’m trying to change the Home Value in GameValues. When the Home Value is changed to the home team (since it is an object value), the scoreboard detects that change and loads the data from the teaminfo module.

I’m trying to figure out why the script isn’t loading properly, as it is working fine in other games, and I’m also trying to figure out secondly how this value is being changed with the scripts provided.

I don’t quite think that’s something I can help with, it sounds more like a debugging adventure that you’ll have to go on to find what other script is editing your value.

Also a quick sidenote, in your teaminfo module, you have a function called Color, which is unecessary, as Color3 has a constructor called fromRGB as well as another one called fromHSV which work as the name implies. It creates a new Color3, but instead of the values being from 0 to 1, they are from 0 to 255 (in the case of RGB).