What I am trying to do is if the player would click the part, a Point Light would add in it and if their mouse left the part, all PointLights would get removed.
game.Workspace.Part.ClickDetector.MouseClick:connect(function() local PointLight = Instance.new("PointLight", game.Workspace.Part) end) game.Workspace.Part.ClickDetector.MouseHoverLeave:connect(function() game.Workspace.Part:GetChildren():remove() end)
All explaining done in the code.
--Your script game.Workspace.Part.ClickDetector.MouseClick:connect(function() local PointLight = Instance.new("PointLight", game.Workspace.Part) end) --Edited game.Workspace.Part.ClickDetector.MouseHoverLeave:connect(function() for _,v in pairs (game.Workspace.Part:GetChildren()) do -- Gather everything in that part if v:IsA("PointLight") then -- If it's a PointLight, don't wanna destroy any script's or anything do you? v:Destroy() -- Destroy it if it's a PointLight end -- End the if end -- End the in pairs end) -- End the mouse hover
Please tell me if it doesn't work, didn't test it.