Hey! I’m trying to make it so that when I click on a certain group of parts, it will change the color of the block. I have all whitelisted parts in a folder.
My mechanism is that when I click red, it will change the CurrentColorChoice variable to the color of the textbox.
However, I’m encountering a problem in the output stating "Unable to assign property Color. Color3 expected, got nil.
local UserInputService = game:GetService("UserInputService")
local StarterGui = game:GetService("StarterGui")
local ColorPaletGui = StarterGui.ColorPaletGui
local ColorsFrame = ColorPaletGui.Colors
local CurrentColorChoice = nil
local Red = ColorsFrame.Red
Red.Activated:Connect(function(input)
print("Red is your current color")
CurrentColorChoice = Color3.new(255,0,0)
end)
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local RaycastParamaterVariables = RaycastParams.new()
RaycastParamaterVariables.FilterType = Enum.RaycastFilterType.Whitelist
RaycastParamaterVariables.FilterDescendantsInstances = game.Workspace.Board:GetChildren()
RaycastParamaterVariables.IgnoreWater = true
local MousePosition = UserInputService:GetMouseLocation()
local MouseRay = game.Workspace.Camera:ScreenPointToRay(MousePosition.X, MousePosition.Y)
local Direction = MouseRay.Direction * 1000
local Result = game.Workspace:Raycast(MouseRay.Origin, Direction, RaycastParamaterVariables)
if Result.Instance then
Result.Instance.Color = CurrentColorChoice
end
end
end)