After changing the ID trough the script, my ImageButton just becomes blank. It still works, yet no image shows up. I’ve heard that I may be using the Decal ID instead of the Image ID, but how do I get it? I’m using a toolbox decal as a placeholder.
Hello, Could you please copy and paste your script here?
I won’t exactly copy and paste, but here is the overall logic that matters
--2 Placeholders from Toolbox
local mutedImage = 4780415369
local normalImage = 80670047522246
local music --Music is defined here. Doesn't matter, it works perfectly
--The script logic, pretty simple.
script.Parent.MouseButton1Click:Connect(function()
music.Playing = not music.Playing --Music will toggle on or off
if music.Playing then
script.Parent.Image = normalImage --If it's playing, put an "On" image
else
script.Parent.Image = mutedImage --Else, an "Off" image
end
end)
cause it has to be a string like:
local mutedImage:string = "rbxassetid://4780415369"
local normalImage:string = "rbxassetid://80670047522246"
Also are you sure that it is an image id and not a decal?
Try pasting id you sent into a decal and copy it from a decal (INSIDE STUDIO NOT DURING GAME); This should automatically convert it to image id.
better way to go about this in my opinion would be
local mutedImage = 4780415369
local normalImage = 80670047522246
script.Parent.Image = "rbxassetid://"..mutedImage
both versions should work, I searched up the decals and tested it in game
How is this “better”?
Dynamically expanding and casting during runtime is anything but better.
Yeah, pasting just the number in studio automatically converts it to the right format. Scripts don’t, though. You need to include “rbxassetid://” like others have said.
it is more readable and prevents futures issues with updating the id and accidentally erasing a slash, that is my opinion though, does casting during runtime cause performance issues? just a question.
I copy pasted the Texture ID and set it to string, it worked!
Ok, added "rbxassetid://"..
Makes sense, I didn’t add the rest of the URL as I thought it converted as well
Of source it does literally look at bytecode.
Bytecode compiler does not unwrap cases like yours.
Gamedev is never about “readability of code”; Gamedev is about perfomance of code.
DONT.
Its bad for perfomance as you see in screenshot above bytecode does not fix cases like this.
Uhh ok?..
But I tried it and when I playtested it started turning blank again
local mutedImage:string = "rbxassetid://4780415369"
script.Parent.Image = mutedImage
This solution works, just make sure you have these two lines the same as yarik
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
