I'm not sure what to say, really. The code is supposed to just change around some text on a billboard GUI whenever a value its connected to changes, but it doesn't seem to want to, and it's giving me a really weird error message that I can't make heads or tails of.
It's only a 40-something line code, and I really don't know why I'm getting the error message, so you'll have to forgive me for posting the entire thing...
PlaceName = script.Parent.Parent.Parent.Name --Find the name of the place, NamDis = script.Parent.NameDisplay --and the display for the name. StatDis = script.Parent.StatDisplay --Then find the display for the place's status, StatusValue = game.Workspace.Statuses:FindFirstChild(PlaceName) --and the value for its status! cols = game.Workspace.ColourCodes NamDis.Text = PlaceName --First of all, we need to make sure that the GUI displays the right name! function ChangeStat() --Neat little function to change the display, based on the base's status value. if StatusValue.Value == 0 then StatDis.Text = "CLEAR" StatDis.TextColor3 = cols.clear.Value end if StatusValue.Value == 1 then StatDis.Text = "RAID" StatDis.TextColor3 = cols.raid.Value end if StatusValue.Value == 2 then StatDis.Text = "OCCUPIED" StatDis.TextColor3 = cols.occupied.Value end end --Now for something really ugly... We want this function to run at the beginning of the game, and I'm awful. So, copypaste. if StatusValue.Value == 0 then StatDis.Text = "CLEAR" StatDis.TextColor3 = cols.clear.Value end if StatusValue.Value == 1 then StatDis.Text = "RAID" StatDis.TextColor3 = cols.raid.Value end if StatusValue.Value == 2 then StatDis.Text = "OCCUPIED" StatDis.TextColor3 = cols.occupied.Value end StatusValue.Value.Changed:connect(ChangeStat)
And here's my output:
13:22:15.879 - Workspace.Zum City.BillboardGui.Frame.Script:45: attempt to index field 'Value' (a number value) 13:22:15.879 - Stack Begin 13:22:15.879 - Script 'Workspace.Zum City.BillboardGui.Frame.Script', Line 45 13:22:15.880 - Stack End
You're getting this error because on line 45 you attempt to index StatusValue.Value
, which is just a number. All you need to do is change StatusValue.Value.Changed
into StatusValue.Changed
:
local PlaceName = script.Parent.Parent.Parent.Name --// I'd recommend using local variables. local NamDis = script.Parent.NameDisplay --and the display for the name. local StatDis = script.Parent.StatDisplay --Then find the display for the place's status, local StatusValue = game.Workspace.Statuses:FindFirstChild(PlaceName) --and the value for its status! local cols = game.Workspace.ColourCodes NamDis.Text = PlaceName --First of all, we need to make sure that the GUI displays the right name! function ChangeStat() --Neat little function to change the display, based on the base's status value. if StatusValue.Value == 0 then StatDis.Text = "CLEAR" StatDis.TextColor3 = cols.clear.Value end if StatusValue.Value == 1 then StatDis.Text = "RAID" StatDis.TextColor3 = cols.raid.Value end if StatusValue.Value == 2 then StatDis.Text = "OCCUPIED" StatDis.TextColor3 = cols.occupied.Value end end ChangeStat(); --// If you want to run the function at the beginning of the game, you can just call it normally; no need to copy-paste. StatusValue.Changed:connect(ChangeStat) --// You're getting `Changed` from StatusValue, not StatusValue.Value.
Hope this helped.