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

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

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

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; ...)

1 comment

0

well it works, sucks that i cant get some quality of life lol

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