Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong with it?

Asked by
Nidoxs 190
10 years ago
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

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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)
Ad

Answer this question