Hey guys, having an issue trying to call a function from a Module script in a local script.
Module Script:
function Settings.Update_Gui(Ammo, StoredAmmo) if Settings.Gui and Settings.CanUpdateGui then Settings.Gui.Frame.AmmoDisplay.Text = Ammo .. "|" .. StoredAmmo --Line 77 end end
Local Script:
local Ammo = script.Ammo -- NumberValue local StoredAmmo = script.StoredAmmo -- NumberValue Settings.Update_Gui(Ammo.Value, StoredAmmo.Value)
Error: Players.Player1.Backpack.M1911.Settings:77: attempt to concatenate local 'StoredAmmo' (a nil value)
Let me know if you can figure out why I am getting this odd error or if you need a bit more information.
Thanks.
I was having this problem myself. It seems that the passed-in arguments get disordered for some reason. I resolved it by passing them in as a tuple instead and then parsing it. In your case I would do the following:
function Settings.Update_Gui(...) local tuple = {...} local Ammo = tuple[1] local StoredAmmo = tuple[2] if Ammo and StoredAmmo then if Settings.Gui and Settings.CanUpdateGui then Settings.Gui.Frame.AmmoDisplay.Text = Ammo .. "|" .. StoredAmmo end end end
And you don't have to change your localscript call.
Well, your first error is that ModuleScripts cannot be called by LocalScripts. Use a ServerScript to use a ModuleScript.
Your second error is that you're not waiting for the children of the script to exist, so:
local StoredAmmo = script:WaitForChild("StoredAmmo")