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

Changing color of multiple parts with a click detector?

Asked by 5 years ago

I am trying to make a quest beacon, the principle goes like this, there are these floating rocks and one of them has a click detector in it, that is the part main, if it is clicked it will change the cursor icon of the click detector (this part works without a problem) but it won't change the color of the bricks. I tried different values both string an numeric but it still doesn't work. In the beginning i thought the problem was in the if declaration but it does change one thing which is the cursor icon so it shouldn't be a problem there.

local model = game.workspace.MysticRocks

local main = model.MainQuest.BrickColor -- Really red 1004 / Cyan 1013

local color1 = model.red1.BrickColor -- Really red / Really blue

local color2 = model.red2.BrickColor -- Crimson / Dark blue

local color3 = model.red3.BrickColor -- Crimson / Dark blue

local color4 = model.red4.BrickColor -- Crimson / Dark blue

local shade1 = model.shade1.BrickColor -- Magenta / Dark indigo

local shade2 = model.shade2.BrickColor -- Bright violet 104 / Royal purple 1031

local shade3 = model.shade3.BrickColor -- Eggplant / Deep blue

local accent = model.pink.BrickColor -- Persimmon / Navy blue

local check = true

script.Parent.MouseClick:connect(function (playerWhoClicked)
if check == true then
    script.Parent.MaxActivationDistance = 0

    accent = BrickColor.new('Persimmon')
    wait(.1)
    shade3 = BrickColor.new('Eggplant')
    wait(.2)    
    shade2 = BrickColor.new(104)
    wait(.3)    
    shade1 = BrickColor.new('Magenta')
    wait(.4)    
    color4 = BrickColor.new('Crimson')
    wait(.5)
    color3 = BrickColor.new('Crimson')
    wait(.6)
    color2 = BrickColor.new('Crimson')
    wait(.7)
    color1 = BrickColor.new('Really red')
    wait(.8)
    main = BrickColor.new(1004)

 script.Parent.CursorIcon = 'rbxgameasset://Images/cursorhelp' -- help cursor
    script.Parent.MaxActivationDistance = 16
check = false
end

if check == false then
    script.Parent.MaxActivationDistance = 0



    accent = BrickColor.new('Navy blue')
    wait(.1)
    shade3 = BrickColor.new('Deep blue')
    wait(.2)    
    shade2 = BrickColor.new (1031)
    wait(.3)    
    shade1 = BrickColor.new('Dark indigo')
    wait(.4)    
    color4 = BrickColor.new('Dark blue')
    wait(.5)
    color3 = BrickColor.new('Dark blue')
    wait(.6)
    color2 = BrickColor.new('Dark blue')
    wait(.7)
    color1 = BrickColor.new('Really blue')
    wait(.8)
    main = BrickColor.new(1013) 


 script.Parent.CursorIcon = 'rbxgameasset://Images/cursor (3)' -- quest cursor
    script.Parent.MaxActivationDistance = 16


check = true

    end
end)
0
http://wiki.roblox.com/index.php/Generic_for . Study the link I provided you with and utilize it on your code. If help is still required then ask. Zafirua 1348 — 5y
0
Pretty interesting concept, so in theory i could just store the parts and colors in different arrays and use a for to change the color of the parts as in part[i] = colorred[i] , am i right? misterdimacugut 11 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

What is happening from my understanding is that you are trying to change a value in a variable, which you cannot do. You would have to change your code to for example

local color4 = model.red4
color4.BrickColor = BrickColor.new("White")

This should solve your problem.

0
Yea it worked, thank you very much, didn't think that could've been a problem in the same place. misterdimacugut 11 — 5y
0
Yeah, I had this problem too when I started coding I had to figure it out through trial and error was annoying lol TiredMelon 405 — 5y
Ad

Answer this question