So I've made this script and it works how I planned (only if used with one part) but I've decided to add more lights. I don't want to have this script into every part and have them named differently. I tried to do it myself and this is what I came up with but doesn't work. Can you guys make it so that this script goes to a model (StageILights) then selects all the parts inside of it and enables the PointLights?
StageILights (model) LigtherSII (Parts)
h = workspace.LightsOn function touch(hit) if hit then h:FindFirstChild("Humanoid") workspace.StageILights:GetChildren("LighterSII").PointLight = true end end script.Parent.Touched:Connect(touch)
Use for i loops to figure out which part has a pointlight and which doesnt
function touch(hit) if hit then local H = hit.Parent:FindFirstChild('Humanoid') if H then local StageILights = workspace:FindFirstChild('StageILights') if StageILights then for _,v in pairs(StageILights:GetChildren()) do if v:FindFirstChild('PointLight') then v.PointLight.Enabled = true end end end end end end script.Parent.Touched:Connect(touch)
I was a little confused by what you are asking, but If I'm understanding correctly this should work
h = workspace.LightsOn function touch(hit) if hit then h:FindFirstChild("Humanoid") local lights = workspace.StageILights:GetChildren("LighterSII") for i, v in pairs(lights) do v.PointLight = true end end end script.Parent.Touched:Connect(touch)