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

Parts staying when should have been made transparent?

Asked by 3 years ago

Hey, basically, when a colour is selected, all the other colours are meant to disappear, but for some reason, this doesn't happen a few rounds in.

For example, the colour is yellow, but it leaves blue parts. I'll leave the code below.

while #game.Players:GetPlayers() < 1 do

    --      S E I
    for i = 1, 10, 1 do

        local colours = {"Red","Orange", "Yellow", "Green", "Dark Blue", "Light Blue", "Pink", "Purple", "White"}
        local randomColour = math.random(1,#colours)
        local Parts = game.Workspace.GameParts:GetChildren()

        print("Get ready!")

        wait(10)

        print ("Selecting safe part...")

        wait(2)

        print(colours[randomColour])

        wait(5)

        local Parts = game.Workspace.GameParts.unsafeParts:GetChildren()

            for i, v in pairs(Parts) do
            if v:IsA("Part") and v.Name == colours[randomColour] then
                v.Parent = game.Workspace.GameParts.safeParts 
                print("Part moved")
            elseif v:IsA("Part")and v.Name ~= randomColour then   
                print("Removing parts.")
                v.Transparency = 1
                v.CanCollide = false
            end
        end

        wait(5)

        print("Parts removed.")

        wait(4)

        --Making the parts visible + can collide
        for i,v in pairs(workspace.GameParts.unsafeParts:GetChildren()) do 
            v.Transparency = 0 
            v.CanCollide = true
            v.Parent = game.Workspace.GameParts.unsafeParts
        end
     end
       print("Game Over! A new round will be starting soon.")
    end

1 answer

Log in to vote
0
Answered by 3 years ago

you are not using the names correctly

Ad

Answer this question