I am trying to make a flashlight when you click it it turns on and when you click it again it turns off. My output keeps on saying "Expected 'end' (to close 'function' at line 5), got 'else'"
Here is my script, pay attention to the tool equipped part.
local Tool = script.Parent
Tool.Equipped:Connect(function(Mouse)
print("Tool was equipped")
Mouse.Button1Down:Connect(function()
print("Tool was clicked")
Tool.Light.Material = "Neon"
Tool.Light.SpotLight.Enabled = true
else
Tool.Light.Material = "Metal"
Tool.Light.SpotLight.Enabled = false
end)
end)
Tool.Unequipped:Connect(function()
print("Tool was unequipped")
Tool.Light.Material = "Metal"
Tool.Light.SpotLight.Enabled = false
end)
thanks!

3 comments
You wrote 'else' but you didn't write 'if'.
do i put "if then"?
or would i put if the mouse is pressed the flashlight will turn off?