Is there anything wrong with my code?
Submit_Button.MouseButton1Click:Connect(function()
ClickSFX:Play()
if Answer["Check-Box"].Check.BackgroundTransparency == 0 then
CorrectSFX:Play()
Answer["Option Text"].TextColor3 = Color3.fromRGB(119, 178, 85)
Answer["Option Text"].Text = Answer["Option Text"].Text.." ✅"
Answer["Option Text"].Font = "GothamBold"
Submit_Button.Visible = false
Next_Button.Visible = true
else if Option1["Check-Box"].Check.BackgroundTransparency == 0 then
Option1["Option Text"] = Option1["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
else if Option2["Check-Box"].Check.BackgroundTransparency == 0 then
Option2["Option Text"] = Option2["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
else if Option3["Check-Box"].Check.BackgroundTransparency == 0 then
Option3["Option Text"] = Option3["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
else if Option4["Check-Box"].Check.BackgroundTransparency == 0 then
Option4["Option Text"] = Option4["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
end
end)
TenBlocke
(Decablocks)
May 27, 2022, 5:29am
#2
Could you please tell us where the error line is coming from
Replace every instance of
else if
with
elseif
like this
Submit_Button.MouseButton1Click:Connect(function()
ClickSFX:Play()
if Answer["Check-Box"].Check.BackgroundTransparency == 0 then
CorrectSFX:Play()
Answer["Option Text"].TextColor3 = Color3.fromRGB(119, 178, 85)
Answer["Option Text"].Text = Answer["Option Text"].Text.." ✅"
Answer["Option Text"].Font = "GothamBold"
Submit_Button.Visible = false
Next_Button.Visible = true
elseif Option1["Check-Box"].Check.BackgroundTransparency == 0 then
Option1["Option Text"] = Option1["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
elseif Option2["Check-Box"].Check.BackgroundTransparency == 0 then
Option2["Option Text"] = Option2["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
elseif Option3["Check-Box"].Check.BackgroundTransparency == 0 then
Option3["Option Text"] = Option3["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
elseif Option4["Check-Box"].Check.BackgroundTransparency == 0 then
Option4["Option Text"] = Option4["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
end
end)
@abcanish123 , I looked on your code and saw your elseif keyword is not properly spelled. You do not want to use the keyword elseif as else if . That is because, it would make another if statements inside your else block. So what your code must be is:
Submit_Button.MouseButton1Click:Connect(function()
ClickSFX:Play()
if Answer["Check-Box"].Check.BackgroundTransparency == 0 then
CorrectSFX:Play()
Answer["Option Text"].TextColor3 = Color3.fromRGB(119, 178, 85)
Answer["Option Text"].Text = Answer["Option Text"].Text.." ✅"
Answer["Option Text"].Font = "GothamBold"
Submit_Button.Visible = false
Next_Button.Visible = true
elseif Option1["Check-Box"].Check.BackgroundTransparency == 0 then
Option1["Option Text"] = Option1["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
elseif Option2["Check-Box"].Check.BackgroundTransparency == 0 then
Option2["Option Text"] = Option2["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
elseif Option3["Check-Box"].Check.BackgroundTransparency == 0 then
Option3["Option Text"] = Option3["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
elseif Option4["Check-Box"].Check.BackgroundTransparency == 0 then
Option4["Option Text"] = Option4["Option Text"].Text.." ❌"
WrongSFX:Play()
Submit_Button.Visible = false
TryAgain_Button.Visible = true
end
end)
See if this works.