I think you were using the link for the asset instead of the texture link..
If you put just the numbers from one of the links "rbxassetid://SOME NUMBERS HERE" into the imagebutton's image property, then roblox will convert the assetid to an image link that you can use in your scripts.
Here's a video showing how to do that: https://streamable.com/0adok
Anyway, I did that for all four of your faces, and put them into a table:
local faces = {
sad = "http://www.roblox.com/asset/?id=4620142770",
neutral = "http://www.roblox.com/asset/?id=4620142572",
mad = "http://www.roblox.com/asset/?id=4620142387",
happy = "http://www.roblox.com/asset/?id=4620142149",
}
Since I put the links in a table, you can now access an image by saying faces.sad or faces.happy etc
You don't have to have them in a table. You can have them as normal variables like you did in your question, but having them in a table allows us to loop through the faces.
It was good that you named your variables, but having them as actual words instead of one letter variables helps you know what things are like in the example above.
To test that all the faces work, I looped through them when the player clicked the button:
local faces = {
sad = "http://www.roblox.com/asset/?id=4620142770",
neutral = "http://www.roblox.com/asset/?id=4620142572",
mad = "http://www.roblox.com/asset/?id=4620142387",
happy = "http://www.roblox.com/asset/?id=4620142149",
}
local imageButton = script.Parent.ImageButton
imageButton.MouseButton1Click:Connect(function()
for expression, image in pairs(faces)do
imageButton.Image = image
wait(.5)
end
end)
if you wanted to make the image be the happy face when you click it you can do the following:
local faces = {
sad = "http://www.roblox.com/asset/?id=4620142770",
neutral = "http://www.roblox.com/asset/?id=4620142572",
mad = "http://www.roblox.com/asset/?id=4620142387",
happy = "http://www.roblox.com/asset/?id=4620142149",
}
local imageButton = script.Parent.ImageButton
imageButton.MouseButton1Click:Connect(function()
imageButton.Image = faces.sad
end)
let me know if you have any more questions
5 comments
What is this supposed to do?
i'm looking into it right now. give me a few minutes. is the script suppsed to cycle thru the faces each time you click? if so, is it supposed to change the face once when you click, or show every face when you click once
It's supposed to be a dialog thing, and when the player clicks on an answer the face changes (I have neutral, happy, sad, mad) and I can change the face by just saying something like "face.Image = h" for happy. I'm new to scripting and trying to make my own stuff to get better... Take that as you will.
Sure thing. I'll do a write up in a sec
Thanks man. :)