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

How do I embed a value change script?

Asked by 6 years ago

I am having problems with this script concerning that sensing of whether the question is right or not right. There is a BoolValue called "QuestionGuess" which is set to true all false depending on when A, B, C or D is selected. The player will then click on one and it will check this bool value to decide whether they have chosen the correct and incorrect answer.

QuestionGuess = script.Parent.QuestionGuess

script.Parent.ButtonMain.MouseButton1Click:connect(function()

            script.Parent.Parent.A.BackgroundColor3 = Color3.fromRGB(47,147,213)
    script.Parent.Parent.A.BorderColor3 = Color3.fromRGB(47,147,213)
    script.Parent.ButtonMain.BackgroundColor3 = Color3.fromRGB(77,146,211)
    script.Parent.ButtonMain.BorderColor3 = Color3.fromRGB(77,146,211)
    wait(1)
script.Parent.Parent.Title.Text = "Checking Your Answer..."
wait(3)

script.Parent.QuestionGuess.Changed:connect(function()
    if QuestionGuess.Value == true then
    script.Parent.Parent.Title.Text = "Correct! Good Job!"
    script.Parent.Parent.A.BackgroundColor3 = Color3.fromRGB(71,167,27)
    script.Parent.Parent.A.BorderColor3 = Color3.fromRGB(71,167,27)
    script.Parent.ButtonMain.BackgroundColor3 = Color3.fromRGB(43,226,64)
    script.Parent.ButtonMain.BorderColor3 = Color3.fromRGB(43,226,64)
   wait()
   elseif QuestionGuess.Value == false then
    game.StarterGui.ApplicationGUI.StrikeDetection.Value = game.StarterGui.ApplicationGUI.StrikeDetection.Value + 1
    script.Parent.Parent.Title.Text = "Incorrect! Unlucky!"
    script.Parent.Parent.A.BackgroundColor3 = Color3.fromRGB(255,12,16)
    script.Parent.Parent.A.BorderColor3 = Color3.fromRGB(255,12,16)
    script.Parent.ButtonMain.BackgroundColor3 = Color3.fromRGB(255,64,67)
    script.Parent.ButtonMain.BorderColor3 = Color3.fromRGB(255,64,67)

end
wait(3)
    script.Parent.Parent.A.BackgroundColor3 = Color3.fromRGB(45,45,45)
    script.Parent.Parent.A.BorderColor3 = Color3.fromRGB(45,45,45)
    script.Parent.ButtonMain.BackgroundColor3 = Color3.fromRGB(70,70,70)
    script.Parent.ButtonMain.BorderColor3 = Color3.fromRGB(70,70,70)
    script.Parent.Parent.Title.Text = "..."
    game.StarterGui.ApplicationGUI.QuestionNumber.Value = game.StarterGui.ApplicationGUI.QuestionNumber.Value + 1
    end)
end)

The problem is the script: "script.Parent.QuestionGuess.Changed:connect(function()" seems to be the error in this script. However, this script needs this in order to tell the button that the bool value has changed. When this is gone, it works but does not sense that the value has changed.

Would I have to use something like:

function QuestionGuess(VALUENAMEHERE)
script.Parent.QuestionGuess.Changed:connect(VALUENAMEHERE)

Thanks!

Answer this question