How can i change multiple colours without using this mess

ok so, im trying to make a button change multiple light colours,
but i can only make it work by doing this mess (it doesnt work actually)
only the color part doesnt work

this mess
workspace.TrainingButton.pert.ProximityPrompt.Triggered:connect(function()
	local part = workspace.Modeljuan
	part:SetPrimaryPartCFrame(CFrame.new(87.74, 2.95, 51.805))
	game.Workspace.TrainingButton.pert.Position = Vector3.new(83.624, 6.357, 87.445)
	game.Workspace.TrainingButton.handler.Position = Vector3.new(83.624, 6.232, 87.445)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	game.Workspace.LIL.Union.PointLight.Color = Color3.new(0.682353, 1, 0)
	script.Parent.Parent.Parent.accept.Decal.Texture = "http://www.roblox.com/asset/?id=5912373783"
	wait(0.000000000001)
	script.Parent:Destroy()

end)

is there any way i can make it work without this mess

speacial thanks @SpacialEthanRB too for helping

You would use a for loop.


for i, part in pairs(game.Workspace.Folder:GetChildren()) do
	part.Color = Color3.fromRGB(0,0,0)
end
2 Likes

For something like this we want to make a loop.

An example which will replace the 40 lines or so changing the color of that 1 part, which thankfully has the same name which will make it easy to change from a loop, is…

for _,v in pairs(workspace.LIL:GetChildren()) do -- We are looping through all the children of the LIL object. For every child this object has, this part of the script runs.
     if v.Name == "Union" then -- v is the actual object which we are working with for this run. We are looking for objects named in a specific way and which are children (contained) in the LIL model.
          v:FindFirstChild("PointLight").Color = Color3.new(0.682353, 1, 0) -- We are looking for the PointLight in every Union, then change the color for it.
     end
end

Also keep in mind ProximityPrompt is a beta feature which will not work in the actual Roblox Launcher, just in Studio. If you really want something like that feature now you can look for a tutorial on the devforum, there are plenty.

1 Like