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

Is my scripting correct for this SpotLight?

So I'm new to scripting ( editing scripts :) ) and I'm trying to get a dynamic SpotLight to have a button to turn it on and off.

The parts to the light are as follows:

Workspace

  • Light -- LightState -- Lamp --- Mesh

--- SpotLight

  • Lightsocket -- Part --- Mesh
  • Switch -- ClickDetector

-- Script

The script is as follows:

--Working lightswitch.

function ToggleLight() if script.Parent.LightState.Value == false then script.Parent.LightState.Value = true script.Parent.Light.SpotLight.Enabled = true else script.Parent.LightState.Value = false script.Parent.Light.SportLight.Enabled = false end end

script.Parent.ClickDetector.MouseClick:connect(ToggleLight)

I don't know if I have enough Parents, or too many, or if something is not in the right order/spelt incorrectly.

Thanks, Harry

P.S. Sorry if tags are wrong, out of my depth here :]

1 answer

Please use the Code Block tab in your writing. It's the button that says "Lua".

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