I know it's gonna be something super obvious that I just didn't figure out 'cause I'm stupid, but for the life of me I can't figure it out. I can set an image when I'm in the editor, I'm changing the gui in the PlayerGui folder, and I just can't get it to work. This is my code:
frame = game.Players.LocalPlayer.PlayerGui.dialog.all main = frame.main face = frame.face op1 = frame.op1 op2 = frame.op2 op3 = frame.op3 s = "rbxassetid://4620142775" n = "rbxassetid://4620142584" m = "rbxassetid://4620142395" h = "rbxassetid://4620142159" script.parent.op1.MouseButton1Click:Connect(function() face.Image = h main.Text = "working" end)
It's a local script, I'm new to scripting, and I'm trying to make my own dialog thing. The main text changes and works like it's supposed to, it's just the image acting up. Thank you to everyone who responds.
EDIT: Also, if you have any tips for making scripts better, like not making so many of those shortened things, please let me know.
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:
--this is a table containing all your reaction images --you can access an image by saying faces.sad, faces.neutral, etc. 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", } --this is your image button to click --i have this script directly inside my gui. --change this to be the location of your image button. local imageButton = script.Parent.ImageButton --function that runs when your image button is clicked imageButton.MouseButton1Click:Connect(function() --this loop displays all the faces inside our faces table 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:
--this is a table containing all your reaction images --you can access an image by saying faces.sad, faces.neutral, etc. 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", } --this is your image button to click --i have this script directly inside my gui. --change this to be the location of your image button. local imageButton = script.Parent.ImageButton --function that runs when your image button is clicked imageButton.MouseButton1Click:Connect(function() imageButton.Image = faces.sad end)
let me know if you have any more questions