Title says it all, its suppost to choose a Image from the list but doesnt do anything, not even a error. The image doesnt come up at all but it prints. Anything wrong with my code?
function RunVideo() local IsPlaying = false while wait(0.5) do if IsPlaying == false then local ImagesForVideo = "2169077935","2169077935","2169077935" local ImageValue = math.random(1,#ImagesForVideo) local TextInsertToImage = "rbxassetid://"..ImageValue script.Parent.BackRoundImageVideo.Image = ImageValue print("Working") end end end
First, the local ImagesForVideo
needs to be a table. Next, you're gonna want to index the table and replace it as your own.
function RunVideo() local IsPlaying = false while wait(0.5) do if IsPlaying == false then local ImagesForVideo = {"2169077935","2169077935","2169077935"} local ImageValue = ImagesForVideo[math.random(1,#ImagesForVideo)] local TextInsertToImage = "rbxassetid://"..ImageValue script.Parent.BackRoundImageVideo.Image = ImageValue print("Working") end end end
Simply, you forgot to add RunVideo()
at the end of the script, which would execute that whole function you've written. It won't run unless you state the function at the end.
All I did was add that:
function RunVideo() local IsPlaying = false while wait(0.5) do if IsPlaying == false then local ImagesForVideo = {"2169077935","2169077935","2169077935"} --always put brackets around a table of values local ImageValue = ImagesForVideo[math.random(1,#ImagesForVideo)] --need to do this to pull a value from the table local TextInsertToImage = "rbxassetid://"..ImageValue script.Parent.BackRoundImageVideo.Image = ImageValue print("Working") end end end RunVideo() --this is important
Try it now.
I barely found out that you cannot change the image in a localscript. Owell just ganna stick to the older one