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

Why is my color3 Replicated Storage value glitching?

Asked by 2 years ago

(Please note that I am new to scripting) I am trying to make a very simple drawing game where once you select a color from a given color selector then you click on a part in the canvas, the canvas part will change depending on what color you selected. I am making this using Replicated Storage. Once color is selected, it changes the color3 value of a replicated storage value named ColorSelector. Then once a canvas part is clicked, the script looks at the color3 value of the Replicated Storage value and changes the color of the canvas part accordingly. Well, that's what I am attempting. A part of my script is not working correctly. It is when the color is selected and you begin to draw with that color. Everything is fine until you go and select another color, then it starts bugging out, switching between the first color you picked and the second color you picked every time you click a new part of the canvas. I saw in the replicated storage color3 value it would start to bug out and alternate between the two color3 values every time you click on a new part of the canvas. I have tried many times in order to resolve this issue, but all were unsuccessful due to my lack of scripting skills. I have attached some codes below, all of which are labeled. If any experienced developer could help me resolve my problems, it would help me advance and overall become a better scripter.

This is the code in one of the Color selectors, making the color red.

local function changecolor()
    while wait{} do 
        game.ReplicatedStorage.ColorValue.Value = Color3.fromRGB(255,0,0)
    end
end


while script.Parent.ClickDetector.MouseClick:Wait() do
    spawn(changecolor)
    return
end

This is the code of one of the canvas parts.

while script.Parent.ClickDetector.MouseClick:Wait(0.01) do
    script.Parent.Color = game.ReplicatedStorage.ColorValue.Value
end

Answer this question