generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Changing ImageButton Value

Previous Thread :: Next Thread 
KodakKid3 is not online. 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 is not online. 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 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
17 Jun 2015 08:01 PM
bump pls
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
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
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
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 is not online. 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
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image