Proximity Prompt Function help

local lightingFolder = game.Workspace:WaitForChild("Lanterns") 

if lightingFolder then 
	for _,Lantern in ipairs(lightingFolder:GetChildren())do   
		Source = Lantern:WaitForChild("Light")
		--Source.PointLight.Enabled = not Source.PointLight.Enabled
		
		--Instancing proximityprompt inside lights
		Prompt = Instance.new("ProximityPrompt",Source)
		Prompt.Exclusivity = "OneGlobally"
		Prompt.HoldDuration = .5
		Prompt.KeyboardKeyCode = "Q"
		Prompt.MaxActivationDistance = 10
		Prompt.ObjectText = "Light"
		Prompt.ActionText = "Toggle"
		
		Prompt.Triggered:Connect(function()
			Prompt.Parent.PointLight.Enabled = not Prompt.Parent.PointLight.Enabled
			if Prompt.Parent.PointLight.Enabled == false then
				Prompt.Parent.Material = Enum.Material.SmoothPlastic
				Prompt.Parent.Color =  Color3.fromRGB(27,42,53)
			else
				Prompt.Parent.Material = Enum.Material.Neon
				Prompt.Parent.Color =  Color3.fromRGB(171,120,86)
				
				
			end
		end)
	end
end

Hey I’m just getting into scripting and am having issues with my lantern script system. While my script does insert the proximity prompts properly into each source actually triggering the prompt at any lantern will only affect one single lantern rather than their parent lantern

maybe use another script for that

I assume you have multiple point lights in a Lantern?

In that case you can use a for i,v in ipairs and then loop through the children checking if it is a Lighsource. Is so, then turn it on.

Prompt.Triggered:Connect(function()
    for _, Child: Instance in ipairs(Lantern:GetChildren()) do -- You could get the lantern by looking at its parents..ig that would be better that storing a reference
        if Child:IsA("Light") then
           -- It depends on how you built those lanterns how you will reference them.,
        end
    end
end)

If you want to turn off all lanterns then you will have to loop through the Folder instead or if your lanterns are built the same way you can simply use the loop we are in to get the lanterns