local Lamp = script.Parent local function onMouseClick(Player) print("Lamp is now on") if script.Parent.PointLight == nil then Point = Instance.new("PointLight") Point.Parent = script.Parent end end Lamp.MouseClick:connect(onMouseClick)
This is my output
19:37:18.907 - PointLight is not a valid member of ClickDetector 19:37:18.907 - Script 'Workspace.Lamp.ClickDetector.Yo', Line 4 19:37:18.908 - Stack End 19:37:18.909 - Disconnected event because of exception
What have I done wrong in this script? If you need more info just ask.
Try this. Your mistakes are described in the comments.
local Lamp = script.Parent.Parent --script.Parent is the ClickDetector, not the lamp. local function onMouseClick(Player) print("Lamp is now on") if Lamp:FindFirstChild("PointLight") == nil then --Use FindFirstChild to avoid errors. Point = Instance.new("PointLight") Point.Parent =Lamp --Parenting the light to a ClickDetector probably won't work. end end script.Parent.MouseClick:connect(onMouseClick)
Locked by 2eggnog, Perci1, and TofuBytes
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?