Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 1 year ago

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

Log in to vote
0
Answered by 1 year ago

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!!

0
Thanks! Jakob_Cashy 79 — 1y
0
Happy to help!! theking66hayday 841 — 1y
Ad

Answer this question