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

Image chooser only works for 1st Image, won't change after 1st is chosen, how do I fix this?

Asked by 1 year ago

This is a LocalScript in a TextButton

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

    local generate = math.random(1,3)
    local Image = script.Parent.Parent.Object.Image
    local Display = script.Parent.Parent.Display.Text
    local Suggestor = script.Parent.Parent.Suggestor.Text

    if generate == 1 then

        script.Parent.Parent.Object.Image = "http://www.roblox.com/asset/?id=10292846756" --change id
        script.Parent.Parent.Display.Text = "Headless Horseman Roblox Avatar"
        script.Parent.Parent.Suggestor.Text = "theking66hayday (thx for help)"

    end

    if generate == 2 then

        Image = "http://www.roblox.com/asset/?id=6258759752"
        Display = "Apple"
        Suggestor = "Owner"

    end

    if generate == 3 then

        Image = "http://www.roblox.com/asset/?id=500109536"
        Display = "Banana"
        Suggestor = "Owner"

    end

end)

It clearly chooses 2 and 3 because I can click the button and a print function says it chose 2/3, but if it chooses 1 it changes the text and image but won't change text or image if pressed again.

1 answer

Log in to vote
1
Answered by 1 year ago

Don't know for sure, but maybe try using the variables in generate == 1 as well, as the variable is already set on the image, or change generate = 2 and generate == 3 from Image =; Display =; and Suggestor =; to writing out the full line (script.Parent.Parent.Suggestor.Text; ...)

0
well it works, sucks that i cant get some quality of life lol Jakob_Cashy 79 — 1y
Ad

Answer this question