Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you deal with multiple models using one script?

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago
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)

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. epoke466 100 — 2y
Ad

Answer this question