Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to do so, when I repeatedly clicked on part, it turned on the light?

Here is a script that i made.

local Lightswitch = workspace.House.Lightswitch
local Light = workspace.Light
workspace.House.Lightswitch.RotatePart.ClickDetector.MouseClick:Connect(function()
	
	Lightswitch.RotatePart.Orientation = Vector3.new(-0, 180, 90) --Turn off
	Light.Light1.PointLight.Enabled = false
	Light.Light2.PointLight.Enabled = false
    Light.Light3.PointLightEnabled = false 
	-- Lightswitch.RotatePart.Orientation = Vector3.new(-0, 0, -90) --Turned on 
end)

Please, help. It will be actually nice.

2 comments

0

Not sure if this will fix your problem but at "Light.Light3.PointLightEnable = false", you forgot to put a period at "PointLight.Enabled".

0

When you are defining the variables you need to add: "game." before workspace.

1 answer

local Lightswitch = workspace.House.Lightswitch
local Light = workspace.Light
local on = false
	workspace.House.Lightswitch.RotatePart.ClickDetector.MouseClick:Connect(function()
		if on == true then
	    	Lightswitch.RotatePart.Orientation = Vector3.new(-0, 180, 90) --Turn off
	    	Light.Light1.PointLight.Enabled = false
	    	Light.Light2.PointLight.Enabled = false
	    	Light.Light3.PointLightEnabled = false
			on = false
		elseif on == false then
			Lightswitch.RotatePart.Orientation = Vector3.new(-0, 0, -90) --Turned on
	    	Light.Light1.PointLight.Enabled = true
	    	Light.Light2.PointLight.Enabled = true
	    	Light.Light3.PointLightEnabled = true
			on = true
		end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.