Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make an ImageLabel Image change if a TextLabel has a specific Text in it?

I just started scripting and want to learn how to make an Image change if a TextLabel says a certain thing.

This is a LocalScript in my ImageLabel, which I thought would turn the Image into a random screenshot I had if the Text below it said 1

if script.Parent.Parent.Display.Text == 1 then
	script.Parent.Image = "https://www.roblox.com/library/11452628830/Images-actual-car-no-texture"
end

This is a LocalScript inside the ScreenGUI

local number = script.Parent.Number
local button = script.Parent.Roll
local Display = script.parent.Display

button.MouseButton1Click:Connect(function()
	number.Value = math.random(1, 2)
end)

number.Changed:Connect(function()
	script.Parent.Display.Text = number.Value
end)

Not sure what's wrong, anything helps!

1 answer

✓ Accepted answer

You only need 1 script. Put this in a textbutton. Local script:

script.Parent.MouseButton1Click:Connect(function(plr)

	local generate = math.random(1,2)

	if generate == 1 then

		script.Parent.Parent.ImageButton.Image = "http://www.roblox.com/asset/?id=10292846756" --change id

	end	

end)

I tested this and it works so Hope this helps!!

2 comments

0

Thanks!

0

Happy to help!!

This discussion is preserved as it was. New answers, comments, and votes are closed.