So I have this script which is supposed to save the value of something, but apparently other GUIs cannot read it, can someone please help me understand how this works?
repeat wait() until script.Parent:findFirstChild("PayDay") repeat wait() until script.Parent.PayDay.Frame:FindFirstChild("BankedMoney") script.Parent.PayDay.Frame.BankedMoney.Changed:connect(function () script.Parent.Parent:SaveNumber("BankedMoney",math.floor(script.Parent.PayDay.Frame.BankedMoney.Value)) end)
When is says 'script.Parent.Parent:SaveNumber' what is it referring to "SaveNumber" is that a part or something?
Also this script is under StarterGUIs section.
First of all we can break this up a little bit to be more readable
repeat wait() until script.Parent:FindFirstChild("PayDay") repeat wait() until script.Parent.PayDay.Frame:FindFirstChild("BankedMoney") script.Parent.PayDay.Frame.BankedMoney.Changed:connect(function () local value = math.floor(script.Parent.PayDay.Frame.BankedMoney.Value) script.Parent.Parent:SaveNumber("BankedMoney", value ) end)
A :
before a name indicates that that name is a method, which means you're doing something to the thing just to the left of the :
.
In this case, we are invoking the SaveNumber
method, which is a member of a Player instance.
That would mean that script.Parent.Parent
ought to a Player object (so script
, the Script, is a Child of a Child of a Player -- for example, a Child of a player's PlayerGui or Backpack)
According to the Wiki, SaveNumber
takes two parameters, a string key
and a double (number) value
. "Used to save a number value that can be loaded again at a later time using LoadNumber"
SaveNumber
may only be used from a normal Script object, not a LocalScript.