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

What is wrong with it?

script.Parent.ClickDetector.MouseClick:connect(function() script.Sound:play() if script.Parent.PointLight.Enabled == true then script.Parent.Light.Enabled = false else script.Parent.PointLight.Enabled = true if script.Parent.ClickDetector.MouseClick:connect(function() PointLight.Sound:pause() end end

Red at line 4 says 'then' expected near 'function' what does this mean and how do I fix it? :(

Help me please!

1 answer

Why do you have two handlers for the event? And you get that error because on line 4 there is an if statement, but no then. Also you need a ) to close :connect(function() on line 1. On top of that, you have script.Parent.PointLight once and script.Parent.Light the second time. Which one is it?

Here's my attempt at fixing it:

script.Parent.ClickDetector.MouseClick:connect(function()
	script.Sound:play()
	if script.Parent.PointLight.Enabled == true then
		script.Parent.PointLight.Enabled = false
	else
		script.Parent.PointLight.Enabled = true
	end
	script.Sound:pause()
end)

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