I'm attempting to make a horror game on Roblox, when you interact with this light switch its supposed to turn them on, but whenever I try it doesn't work, and the output says,"Workspace.Lights.Part.Script:3: attempt to call a nil value" what does this mean?
my code:
script.Parent.ProximityPrompt.Triggered:Connect(function() local light = script.Parent.Parent:GetChildren("Light") local pointlight = light:GetChildren("PointLight") pointlight.Enabled = true local click = light:GetChildren("Click") click:Play() script.Parent.ProximityPrompt.Enabled = false end)
please help.
For getting a object use :WaitForChild().
Here is the fixed code
script.Parent.ProximityPrompt.Triggered:Connect(function() local light = script.Parent.Parent:WaitForChild("Light") local pointlight = light:WaitForChild("PointLight") pointlight.Enabled = true local click = light:WaitForChild("Click") click:Play() script.Parent.ProximityPrompt.Enabled = false end)