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

I'm trying to get the property of an item inside part inside a model, Please help?

I have no idea how to do this, I've attempting this to work through a GUI & be able to be triggered from a model if need be. Basically, lets use ArenaLights as the main model.

Lighting = game.Lighting
ReplicatedStorage = game.ReplicatedStorage
parts = game.Workspace.ArenaLights:GetChildren() 
--------------------------------
game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight)
	if arenalight == "BrightWhite" then --White Lighting
		parts.PointLight.Color = Color3.new(255/255,255/255,255/255)
		wait(0.01)
	elseif arenalight == "White" then
		parts.PointLight.Color = Color3.new(255/255,255/255,255/255)
		wait(0.01)
	elseif arenalight == "Blackout" then
		parts.PointLight.Color = Color3.new(0/255,0/255,0/255)
		wait(0.01)
	end
end)

Thank you in advance for any help you may give and any time you spend on this!

2 comments

0

What are you trying to do??

0

Alright so, i'm attemtping to get PointLight from Multiple parts inside a model to change color.

2 answers

✓ Accepted answer

Try This:

Lighting = game:GetService('Lighting') -- This line isn't needed though.
ReplicatedStorage = game.ReplicatedStorage
parts = game.Workspace.ArenaLights:GetChildren() 
--------------------------------
game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight)
    if arenalight == "BrightWhite" then --White Lighting
		for i,v in pairs(parts) do
	        v.PointLight.Color = Color3.new(255/255,255/255,255/255)
	        wait(0.01)
		end
		wait(0.01)
    elseif arenalight == "White" then
		for i,v in pairs(parts) do
	        v.PointLight.Color = Color3.new(255/255,255/255,255/255)
	        wait(0.01)
		end
		wait(0.01)
    elseif arenalight == "Blackout" then
		for i,v in pairs(parts) do
	        v.PointLight.Color = Color3.new(0/255,0/255,0/255)
	        wait(0.01)
		end
		wait(0.01)
    end
end)

3 comments

0

First time using the site. (:

0

Please provide explanations with your post. If OP does not understand this, look at my answer. I explained it :)

0

After re-looking at this as a better scripter; please add a local before everyone variable.

If I understood correctly you want to change all the PointLights inside of all the Parts inside of ArenaLights.

The simplest loop is just using a i, v pairs loop. This will loop through a list of items, in this case a list of all the children in the ArenaLights object, and give you the index (number) of the child and the child itself.

for index, child in pairs(game.Workspace.ArenaLights:GetChildren()) do
	-- Code in here will run for every single child independently.
	-- Example:
	child.PointLight.Color = Color3.fromRGB(255, 255, 255)
end

The correct usage is using i,v instead of index, child. I fixed your code for you, but it'd be good practice to try to fix it yourself using the above information. I've also used Color3.fromRGB() instead of Color3.new() because it's easier to work with.


Lighting = game.Lighting
ReplicatedStorage = game.ReplicatedStorage

--------------------------------

game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight)
    local children = game.Workspace.ArenaLights:GetChildren()
    if arenalight == "BrightWhite" then --White Lighting
        for i, v in pairs(children) do
			v.PointLight.Color = Color3.fromRGB(255, 255, 255)
		end
		wait(0.01)
    elseif arenalight == "White" then
        for i, v in pairs(children) do
			v.PointLight.Color = Color3.fromRGB(255, 255, 255)
		end
        wait(0.01)
    elseif arenalight == "Blackout" then
        for i, v in pairs(children) do
			v.PointLight.Color = Color3.fromRGB(0, 0, 0)
		end
        wait(0.01)
    end
end)

2 comments

0

Yours showed up as a nil value

0

Oops sorry, my mistake. I fixed it!

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