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

How do you deal with multiple models using one script?

I'm trying to make it to where when I use a proximity prompt, the LIGHTS turn on. I don't have any code snips since I don't have a clue on how to even start.

1 answer

local lightsFolder = workspace.LightsFolder:GetChildren() --Light Model (NOT THE SAME PART/MODEL AS THE PROXIMITY PROMPT)

script.Parent.ProximityPrompt.TriggerEnded:Connect(function()
	for i,v in pairs(lightsFolder) do
		v.PointLight.Enabled = true
	end
end)

This will turn the lights under the model/Folder on (it will not turn them off)

1 comment

0

To make them flip between on and off you can use v.PointLight.Enabled = not v.PointLight.Enabled instead of v.PointLight.Enabled = true on line 5. Note that this just flips the value. If some are on and others are off, the ones that are on will turn off and vice versa.

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