Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

(SOLVED) Unable to Change Lights Color with a Value?

Hello, My main issue is when Changing a ***Color3 ***Light with a Value, Which Does not change color & Continues to Go Pure (0,0,0)

Perhaps I may be Doing this wrong? Any Help would Be greatful for what I need to do to get it to work.

ServerSideScript

script.ColorEvent.OnServerEvent:Connect(function(player,ColorChoiceButtons,ButtonColorOfChoice)
	local Light = workspace.Part.PointLight
	Light.Color = Color3.new(ButtonColorOfChoice)
end)

Client Script GUI

local ColorChoiceButtons = ThemePage.Selection_Menu


local ColorEventRequire = LightLocal.ColorChanged_Event.ColorFunctionAsset.ColorEvent


local Buttons = ColorChoiceButtons

for i,v in pairs (Buttons:GetChildren()) do
	if v:IsA("TextButton") or v:IsA("ImageButton") then
		v.MouseButton1Click:Connect(function(player)
			print('Color '..v.Name..' Was Selected!')
			local ButtonColorOfChoice = v.ContainedColor.Value
			ColorEventRequire:FireServer(player,ColorChoiceButtons,ButtonColorOfChoice)
		end)
	end
end

2 comments

0

are you sure v.ContainedColor.Value is a color value that ranges from 0,0,0 to 1,1,1?

0

v.ContainedColor Is a "ColorValue" that is inside the button That the Client Clicked, Then the script Gets the Value for the Serverscript, and Put its towards the Light Color.

1 answer

As @S0NIC_Dev said, v.ContainedColor is a ValueObject which obtains a Color3 value, then why do you need to do this?

Color3.new(--[[Color3 again???--]])

You can just do:

script.ColorEvent.OnServerEvent:Connect(function(player,ColorChoiceButtons,ButtonColorOfChoice)
    local Light = workspace.Part.PointLight
    Light.Color = ButtonColorOfChoice
end)

Also debug first, since the script is associated with many factors.

Color3

Edit: Help you fix your codes...

--Server
script.ColorEvent.OnServerEvent:Connect(function(player,c)
    local Light = workspace.Part.PointLight
    Light.Color = c--It's a color3 class as you said...
end)

--Client
--I assume ContainedColor is a Color3 value object...
local ColorChoiceButtons = ThemePage.Selection_Menu


local ColorEventRequire = LightLocal.ColorChanged_Event.ColorFunctionAsset.ColorEvent

for i,v in pairs (ColorChoiceButtons:GetChildren()) do
    if v:IsA("TextButton") or v:IsA("ImageButton") then
        v.MouseButton1Click:Connect(function(player)
            print('Color '..v.Name..' Was Selected!')
		
            ColorEventRequire:FireServer(player,v.ContainedColor.Value)
        end)
    end
end

2 comments

0

However, ContainedColor is a Color3 Value... And It ends up outputing: invalid argument #3 (Color3 expected, got Instance)

0

since you didn't realize your mistake let me just fix your code in edit

This discussion is preserved as it was. New answers, comments, and votes are closed.