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

is this the way to change color of pointlight in a FE game?

normal script in workspace.

local remote = Instance.new('RemoteFunction', game:GetService('ReplicatedStorage'));
remote.Name = 'Utility';

local part = workspace.Part;

remote.OnServerInvoke = function(player, command, ...) --// ... used here makes this a variadic function. Link to an explanation is at the bottom of this answer.
    local args = {...} --// Turn the extra arguments into a table.
    if command == 'colour' then
		elseif command == 'light' then
		local colour = args[1]
		part.PointLight.Color = ColorSequence.new(colour)
        if type(colour) == 'string' then
            part.BrickColor = BrickColor.new(colour); --// Ideally, you'd check if it's a valid colour with a table. Skipping this for the example.
        end;
    end;
end;

local script in startergui.

script.Parent.MouseButton1Click:connect(function()
	local remote = game:GetService('ReplicatedStorage'):WaitForChild('Utility');
	remote:InvokeServer('colour', '255,0,0');
end)

i want to change a pointlight color in workspace when a gui is clicked. since i didnt want to use alot of remote events for each color @Pyrondon came up an easier way for me to do it with brick's but i just want to know how would i use this for pointlights? i apologize @Pyrondon i am not a great scripter so i dont know if this is what you meant. Any help appreciated as all ways. Thank you. @Pyrondon 's script for bricks. https://scriptinghelpers.org/questions/35473/how-can-i-use-1-remote-eventfunction-for-multiple-things

1 answer

There are a few things to note:

1: You are sending the command "colour" in the LocalScript but the corresponding if statement in the Script is empty (instead the color is changed in "light"). 2: You are setting the PointLight's color to a ColorSequence (I have been away a while so this may be valid, but it strikes me as unusual. Also, the wiki does not provide it with a string constructor.) 3: You are sending a string which looks like it wants to be a Color3. My short experiments with this have resulted in it defaulting to Medium Stone Grey. Same probably goes for the Color3 constructor with a string. You can send a Color3 value (and quite a lot of values) using RemoteFunctions and RemoteEvents.

Try sending a Color3 value from the LocalScript and assigning PointLight's color to it directly, then setting part's Color value directly to the color (I have seen some conflicting information on this, so it may not be valid when not in Studio. In that case, set part's BrickColor to BrickColor.new(color))

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