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

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

Asked by 3 years ago
Edited 3 years ago
--###----------[[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]

0
Try modifying each Image in one program. Ziffixture 6913 — 3y
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)]" yuni_Boy1234 320 — 3y
0
yuni_Boy1234, if you want rep, just put an answer, because this works lol Jakob_Cashy 79 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
--###----------[[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)

0
totally didnt expected for it to work lol yuni_Boy1234 320 — 3y
Ad

Answer this question