Hi guys! Today, I edited my colour-changing script, but it is broken. After I saw the log, I thought it was because of the error message saying “Attempt to index nil with R”. So, look between lines 512 and 540:
local function updateColourPreview()
local hueMinXPos = hue2Btn.AbsolutePosition.X
local hueMaxXPos = hueMinXPos + hue2Btn.AbsoluteSize.X
local hueMinYPos = hue.AbsolutePosition.X
local hueMaxYPos = hueMinYPos + hue.AbsoluteSize.X
local cMinXPos = cyanBtn.AbsolutePosition.X
local cMaxXPos = cMinXPos - cyanBtn.AbsoluteSize.X
local kMinXPos = keyBtn.AbsolutePosition.X
local kMaxXPos = kMinXPos - keyBtn.AbsoluteSize.X
local mMinXPos = magentaBtn.AbsolutePosition.X
local mMaxXPos = mMinXPos - magentaBtn.AbsoluteSize.X
local yMinXPos = yellowBtn.AbsolutePosition.X
local yMaxXPos = yMinXPos - yellowBtn.AbsoluteSize.X
local satMinXPos = satBtn.AbsolutePosition.X
local satMaxXPos = satMinXPos - satBtn.AbsoluteSize.X
local valueMinXPos = valueBtn.AbsolutePosition.X
local valueMaxXPos = valueMinXPos - valueBtn.AbsoluteSize.X
local redMinXPos = redBtn.AbsolutePosition.X
local redMaxXPos = redMinXPos - redBtn.AbsoluteSize.X
local greenMinXPos = greenBtn.AbsolutePosition.X
local greenMaxXPos = greenMinXPos - greenBtn.AbsoluteSize.X
local blueMinXPos = blueBtn.AbsolutePosition.X
local blueMaxXPos = blueMinXPos - blueBtn.AbsoluteSize.X
local hueXPixelSize = hueMaxXPos - hueMinXPos
local hueYPixelSize = hueMaxYPos - hueMinYPos
local cyanXPixelSize = cMaxXPos - cMinXPos
local keyXPixelSize = kMaxXPos - kMinXPos
local magentaXPixelSize = mMaxXPos - mMinXPos
local yellowXPixelSize = yMaxXPos - yMinXPos
local saturationXPixelSize = satMaxXPos - satMinXPos
local valueXPixelSize = valueMaxXPos - valueMinXPos
local redXPixelSize = redMaxXPos - redMinXPos
local greenXPixelSize = greenMaxXPos - greenMinXPos
local blueXPixelSize = blueMaxXPos - blueMinXPos
local hueSliderX = hue2Picker.AbsolutePosition.X
local hueSliderY = huePicker.AbsolutePosition.Y
local cSliderX = cyanPicker.AbsolutePosition.X
local kSliderX = keyPicker.AbsolutePosition.X
local mSliderX = magentaPicker.AbsolutePosition.X
local ySliderX = yellowPicker.AbsolutePosition.X
local saturationSliderX = satPicker.AbsolutePosition.X
local valueSliderX = valuePicker.AbsolutePosition.X
local redSliderX = redPicker.AbsolutePosition.X
local greenSliderX = greenPicker.AbsolutePosition.X
local blueSliderX = bluePicker.AbsolutePosition.X
local hueXPos = (hueSliderX - hueMinXPos) / hueXPixelSize
local hueYPos = (hueSliderY - hueMinYPos) / hueYPixelSize
local cyanXPos = (cSliderX - cMinXPos) / cyanXPixelSize
local keyXPos = (kSliderX - kMinXPos) / keyXPixelSize
local magentaXPos = (mSliderX - mMinXPos) / magentaXPixelSize
local yellowXPos = (ySliderX - yMinXPos) / yellowXPixelSize
local satXPos = (saturationSliderX - satMinXPos) / saturationXPixelSize
local valueXPos = (valueSliderX - valueMinXPos) / valueXPixelSize
local redXPos = (redSliderX - redMinXPos) / redXPixelSize
local blueXPos = (blueSliderX - blueMinXPos) / blueXPixelSize
local greenXPos = (greenSliderX - greenMinXPos) / greenXPixelSize
local Saturation = returnColor(satXPos, satBtn.SatGradient.Color.Keypoints)
local satR, satG, satB = 255 + math.floor(Saturation.R * 255), 255 + math.floor(Saturation.G * 255), 255 + math.floor(Saturation.B * 255)
local Value = returnColor(valueXPos, valueBtn.ValueGradient.Color.Keypoints)
local valueR, valueG, valueB = 255 - math.floor(Value.R * 255), 255 - math.floor(Value.G * 255), 255 - math.floor(Value.B * 255)
local hueX = returnColor(hueXPos, hue2Btn.HueGradient.Color.Keypoints)
local hue2R, hue2G, hue2B = math.floor(hueX.R * 255), math.floor(hueX.G * 255), math.floor(hueX.B * 255)
local hueY = returnColor(hueYPos, hue.UIGradient.Color.Keypoints)
local hueR, hueG, hueB = math.floor(hueY.R * 255), math.floor(hueY.G * 255), math.floor(hueY.B * 255)
local Cyan = returnColor(cyanXPos, cyanBtn.UIGradient.Color.Keypoints)
local cyanR, cyanG, cyanB = math.floor(Cyan.R * 0), math.floor(Cyan.G * 255), math.floor(Cyan.B * 255)
local Magenta = returnColor(magentaXPos, magentaBtn.UIGradient.Color.Keypoints)
local magentaR, magentaG, magentaB = math.floor(Magenta.R * 255), math.floor(Magenta.G * 0), math.floor(Magenta.B * 255)
local Yellow = returnColor(yellowXPos, yellowBtn.UIGradient.Color.Keypoints)
local yellowR, yellowG, yellowB = math.floor(Yellow.R * 255), math.floor(Yellow.G * 255), math.floor(Yellow.B * 0)
local Red = returnColor(redXPos, redBtn.RedGradient.Color.Keypoints)
local r, rg, rb = math.floor(Red.R * 255), math.floor(Red.G * 0), math.floor(Red.B * 0)
local Green = returnColor(greenXPos, greenBtn.GreenGradient.Color.Keypoints)
local g, gr, gb = math.floor(Green.G * 255), math.floor(Green.R * 0), math.floor(Green.B * 0)
local Blue = returnColor(blueXPos, blueBtn.BlueGradient.Color.Keypoints)
local b, br, bg = math.floor(Blue.B * 255), math.floor(Blue.R * 0), math.floor(Blue.G * 0)
local resultColour = Color3.fromRGB(hue2R - valueR, hue2G - valueG, hue2B - valueB)
currentColour.BackgroundColor3 = resultColour
end
function updateHexPreview(enterpressed)
if enterpressed then
currentColour.BackgroundColor3 = hexBox.Text
end
end
hue2Picker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
valuePicker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
cyanPicker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
magentaPicker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
yellowPicker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
keyPicker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
redPicker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
greenPicker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
bluePicker:GetPropertyChangedSignal("Position"):Connect(updateColourPreview)
hexBox.FocusLost:Connect(updateColourPreview)
How does the colour picker GUI work when it changes when the slider is moving?