Hey there! I have a lightswitch script which doesnt allow the light to be turned off or on if it is already changing. The script utilizes ProximityPrompts that I recently recoded to make the light-change a tween! It all seems to work fine, but it is now broken and I get the error " syntax error expected ) to close '('at line 10, got 'end' "
I've looked online to see what I should do, but the syntax error confuses me because the function already seems closed as line 10 is the line that triggers with the ProximityPrompt activation/connection. Here is the code that I have :
local Light = game.Workspace.LivingRoomLamp2L.PointLight local LightOn = false local InProgress = false local prompt = game.Workspace.LivingRoomLamp2.ProximityPrompt local Info = TweenInfo.new(1) local Tween = game:GetService("TweenService"):Create(Light,Info,{Brightness=1})--Light on local Info2 = TweenInfo.new(1) local Tween2 = game:GetService("TweenService"):Create(Light,Info2,{Brightness=0})--Light off prompt.Triggered:Connect(function()--Proximity prompt triggered. This is where the error is if InProgress == false then InProgress = true if LightOn == false then script.Parent.Switch:Play()--Sound Tween:Play() --Light on workspace.LampLiving.LampLight.Light.Material = Enum.Material.Neon prompt.ActionText = "Turn off lamp" --Textchange wait (0.05) --Lights on wait(0.05) LightOn = true --Light is on else script.Parent.Switch:Play()--Sound Tween2:Play() --Light off workspace.LampLiving.LampLight.Light.Material = Enum.Material.Metal wait(0.05) prompt.ActionText = "Turn on lamp" --Textchange wait (0.05) --Lights off end LightOn = false end InProgress = false end end)
I am unsure how to change this or what I should possibly do to remedy the error. Any advice would be appreciated, thank you! Sorry if my code is a mess in advance.
The error is very simple. You just added an extra end in one of your ends, hence the error. To resolve this problem, simply, take out one of the ends and you'll be set!
local Light = game.Workspace.LivingRoomLamp2L.PointLight local LightOn = false local InProgress = false local prompt = game.Workspace.LivingRoomLamp2.ProximityPrompt local Info = TweenInfo.new(1) local Tween = game:GetService("TweenService"):Create(Light,Info,{Brightness=1})--Light on local Info2 = TweenInfo.new(1) local Tween2 = game:GetService("TweenService"):Create(Light,Info2,{Brightness=0})--Light off prompt.Triggered:Connect(function()--Proximity prompt triggered. This is where the error is if InProgress == false then InProgress = true if LightOn == false then script.Parent.Switch:Play()--Sound Tween:Play() --Light on workspace.LampLiving.LampLight.Light.Material = Enum.Material.Neon prompt.ActionText = "Turn off lamp" --Textchange wait (0.05) --Lights on wait(0.05) LightOn = true --Light is on else script.Parent.Switch:Play()--Sound Tween2:Play() --Light off workspace.LampLiving.LampLight.Light.Material = Enum.Material.Metal wait(0.05) prompt.ActionText = "Turn on lamp" --Textchange wait (0.05) --Lights off LightOn = false end InProgress = false end end)