KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 17 Jun 2015 07:20 PM |
So nested in a gui in StarterGui is an InventorySlots frame which contains 20 ImageButtons, each containing an IntValue called Decal. Events in the game will cause that IntVal to change to the ID of a decal, and this script is supposed to check these ImageButtons and when one of their Decal Intvalues is changed to a decal ID, update the Image value of the ImageButton.
The decal Intvalues, which are set at default to 0, are successfully changed to the ID of the decals I want, but the Image value of the ImageButtons won't change. Any idea why? The Image value of them is default set to rbxassetid:// if it matters, and the decal ID number is supposed to just be added to this.
while wait() do for i, v in pairs(script.Parent.InventSlots:GetChildren()) do if v.Decal.Value > 0 then v.Image = "rbxassetid://" .. v.Decal.Value end end end
--Thanks |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 17 Jun 2015 07:24 PM |
| Also, the game errors initially because the Image values are set only to rbxassetid:// , and that isn't any image, so it errors. Could this be causing it somehow? |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
| |
|
|
| 17 Jun 2015 08:07 PM |
It's possibly because you aren't accounting for the number actually being the web URL number - 1? If you already are, then I'm not sure. But instead of a wait loop, a changed event would be better.
for _, slot in pairs(script.Parent.InventSlots:GetChildren()) do slot.Changed:connect(function() slot.Image = "rbxassetid://" .. v.Decal.Value end) end
If that doesn't work, try:
for _, slot in pairs(script.Parent.InventSlots:GetChildren()) do slot.Changed:connect(function() slot.Image = "rbxassetid://" .. v.Decal.Value - 1 end) end
And if that still doesn't work.. I dunno, man.
-The [Guy] |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2015 08:08 PM |
Sorry I forgot to change one of the v's.
for _, slot in pairs(script.Parent.InventSlots:GetChildren()) do slot.Changed:connect(function() slot.Image = "rbxassetid://" .. slot.Decal.Value - 1 end) end
That's the -1 version. just remove the -1 if that doesn't work. and if that still doesn't work, then yeah. dunno. :P
-The [Guy] |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 17 Jun 2015 08:26 PM |
I'm already accounting for the -1, so i tried what you suggested, still not working.
Could it be because the for loop only runs once, so once it's finished running, the changed function no longer matters? |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 11:46 AM |
No. Once a function is connected like that, it should stay connected until the character changes.
-The [Guy] |
|
|
| Report Abuse |
|
|