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

The colors on my dancefloor wont change can someone please help?

Asked by 7 years ago

I made this script for my SurfaceGui dancefloor and it doesnt seem to be changing the colors.

while true do
    wait(1.2,a)
    a = math.random(1, 23)
    if a == 1 then script.Recieve.Value = 1 end
    if a == 2 then script.Recieve.Value = 2 end
    if a == 3 then script.Recieve.Value = 3 end
    if a == 4 then script.Recieve.Value = 4 end
    if a == 5 then script.Recieve.Value = 5 end
    if a == 6 then script.Recieve.Value = 6 end
    if a == 7 then script.Recieve.Value = 7 end
    if a == 8 then script.Recieve.Value = 8 end
    if a == 9 then script.Recieve.Value = 9 end
    if a == 10 then script.Recieve.Value = 10 end
    if a == 11 then script.Recieve.Value = 11 end
    if a == 12 then script.Recieve.Value = 12 end
    if a == 13 then script.Recieve.Value = 13 end
    if a == 14 then script.Recieve.Value = 14 end
    if a == 15 then script.Recieve.Value = 15 end
    if a == 16 then script.Recieve.Value = 16 end
    if a == 17 then script.Recieve.Value = 17 end
    if a == 18 then script.Recieve.Value = 18 end
    if a == 19 then script.Recieve.Value = 19 end
    if a == 20 then script.Recieve.Value = 20 end
    if a == 21 then script.Recieve.Value = 21 end
    if a == 22 then script.Recieve.Value = 22 end
    if a == 23 then script.Recieve.Value = 23 end
end

while true do
    wait(1.2)
    if script.Recieve.Value == 1 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=36527248"
    end
    if script.Recieve.Value == 2 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=60942535"
    end
    if script.Recieve.Value == 3 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=156956412"
    end
    if script.Recieve.Value == 4 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=51598825"
    end
    if script.Recieve.Value == 5 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=94957551"
    end
    if script.Recieve.Value == 6 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=81320375"
    end
    if script.Recieve.Value == 7 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=135527000"
    end
    if script.Recieve.Value == 8 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=23043720"
    end
    if script.Recieve.Value == 9 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=38053520"
    end
    if script.Recieve.Value == 10 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=190632862"
    end
    if script.Recieve.Value == 11 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=226024901"
    end
    if script.Recieve.Value == 12 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=51891163"
    end
    if script.Recieve.Value == 13 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=35895251"
    end
    if script.Recieve.Value == 14 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=110490672"
    end
    if script.Recieve.Value == 15 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=91463232"
    end
    if script.Recieve.Value == 16 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=50273242"
    end
    if script.Recieve.Value == 17 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=215418202"
    end
    if script.Recieve.Value == 18 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=3941993"
    end
    if script.Recieve.Value == 19 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=36527069"
    end
    if script.Recieve.Value == 20 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=148955640"
    end
    if script.Recieve.Value == 21 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=501633538"
    end
    if script.Recieve.Value == 22 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=470025936"
    end
    if script.Recieve.Value == 23 then
        script.Parent.SurfaceGui.ImageLabel.Image = "http://www.roblox.com/asset/?id=12271978"
    end
end
0
This is a wild guess, but switch wait(1.2,a) and a = math.random(1, 23)? a = math.random(1, 23) should be before the wait MEANDUDE87 60 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago

Your code is WAY too complicated to understand! Let's simplify it by making a table. Also, you should delete the Receive object because it is not necessary to use it. Let me show you how to do it!

Click here to know more about tables!

This is an example, put ALL your image ID (They must be subtracted by 1 before inputting them) into the images table!

local images = {36527248, 60942535, 156956412, 51598825, 94957551, 81320375, 135527000} -- I'm not gonna put all the assets for you, try putting them yourself! ;)

local imageLabel = script.Parent.SurfaceGui.ImageLabel

while true do
    imageLabel.Image = "http://www.roblox.com/asset/?id="..images[math.random(1, #images)] -- Chooses a random imageId for the dance floor and concatenates it with the link! This will change the images itself randomly.
    wait(1.2)
end

Also, infinite loops won't end unless you put a break at the end. This is another reason why your script does not work.

If you have any questions, please leave a comment below. Thank you and I hope this will help you! :D -CStarLam

0
Okay thanks mate that worke OfficerJorden139 5 — 7y
0
Click the check mark to accept my answer, we'll both get reputation that way and it will prove that the question is resolved! :D starlebVerse 685 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

format First of all, at the start of the script you should just put script.Recieve.Value=a and remove those unneccesary lines of code.

I clicked on the links, and it leads to a single color image. This is unnecesary, just change the background color and remove the image of the imagelabel.

solution You also have two while true loops, and this may be the core of your problem. The second loop will only run after the first has finished running. As far as i can see, splitting them into two is unnecessary and you can combine them after all.

Hope this helps!

Answer this question