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

Why do the two ImageLabels always show the same image, even though they are random?

--###----------[[SERVICES]]----------###--
local Players = game:GetService("Players")



--###----------[[VARIABLES]]----------###--
local Player = Players.LocalPlayer

local PlayerGui = Player:WaitForChild("PlayerGui")

local RollButton = PlayerGui:WaitForChild("RollButton")
local BuFoRol = RollButton:WaitForChild("BuFoRol")


local ImageBMS = {
	4967482266,
	4967478161,
	5723075768,
	5723077460,
	5723079075,
	5723081342;
}


local ImageLabel = script.Parent



--###----------[[FUNCTIONS]]----------###--
local function SetRandomImage()
	local RandomImageID = ImageBMS[Random.new(tick()):NextInteger(1, #ImageBMS)]
	---------------
	ImageLabel.Image = "rbxassetid://"..RandomImageID
end



--###----------[[SETUP]]----------###--
BuFoRol.MouseButton1Click:Connect(SetRandomImage)

This is the script inside two different imagelabels, after changing them 15 time sin a row, they both showed the same image from all of the times i changed them, i wnat to make them show random images, that differentiate from the other one. How would I do that?

to see what happening go here: [https://www.youtube.com/watch?v=pNBtULkpefc&feature=youtu.be]

3 comments

0

Try modifying each Image in one program.

0

If i were you in line 31, i would do instead ImageBMS[math.random(1, #ImageBMS}], or maybe try doing on line 33 "ImageLabel.Image = "rbxassetid://"..ImageBMS[math.random(1, #ImageBMS)]"

0

yuni_Boy1234, if you want rep, just put an answer, because this works lol

1 answer

✓ Accepted answer
--###----------[[SERVICES]]----------###--
	local Players = game:GetService("Players")
	 
	 
	 
	--###----------[[VARIABLES]]----------###--
	local Player = Players.LocalPlayer
	 
	local PlayerGui = Player:WaitForChild("PlayerGui")
	 
	local RollButton = PlayerGui:WaitForChild("RollButton")
	local BuFoRol = RollButton:WaitForChild("BuFoRol")
	 
	 
	local ImageBMS = {
	    4967482266,
	    4967478161,
	    5723075768,
	    5723077460,
	    5723079075,
	    5723081342;
	}
	 
	 
	local ImageLabel = script.Parent
	 
	 
	 
	--###----------[[FUNCTIONS]]----------###--
	local function SetRandomImage()
	    ---------------
	    ImageLabel.Image = "rbxassetid://"..ImageBMS[math.random(1, #ImageBMS)] --Selects a random index from the table
	end
	 
	 
	 
	--###----------[[SETUP]]----------###--
	BuFoRol.MouseButton1Click:Connect(SetRandomImage)

1 comment

0

totally didnt expected for it to work lol

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