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

My StringValue Isn't Changing?

Asked by 4 years ago

Hey, so I'm making an application center for my group I'm making, but in my script a StringValue is supposed to change so that the server can recognize if the player got the correct answer or not, but my StringValue just isn't changing. My script:

(Client Button)

script.Parent.MouseButton1Click:Connect(function()
    local current = script.Parent.Parent.Selected.Value
    if current == "None" then
        script.Parent.Text = "X"
        script.Parent.Parent.Selected.Value = "D"
    elseif current ~= "D" then
        local switch = current.."B"
        script.Parent.Parent:FindFirstChild(switch).Text = ""
        script.Parent.Text = "X"
        script.Parent.Parent.Selected.Value = "D"
    end
end)

(Server)

script.Parent.Parent.Parent.Submit.END.MouseButton1Click:Connect(function()
    local q = script.Parent.Parent.Parent.Q1.Selected.Value
    local a = script.Parent.Parent.Parent.Q1.Right.Value
    if a == q then
        script.Parent.Text =  " ?"
        script.Parent.Parent.Right.Value = script.Parent.Parent.Right.Value + 1
    else
        script.Parent.Text = "X"
    end
end)

Thanks in advance.

1 answer

Log in to vote
0
Answered by 4 years ago

I would change the way that you are checking to see if a question was right.

Local script that is inside the button, here is some pseudocode

script.Parent.MouseButton1Click:Connect(function()
    local current = script.Parent.Parent.Selected.Value
    if theCurrentIsAtLeastValid then
        local res = -- use a remote function to see if the answer is correct

        if the server told us it was the correct answer then
            -- tell the user they got is correct
        else
            -- tell the user they got it incorrect
        end
    else
        -- tell the user their input is not valid
    end
end)

Server script in ServerScriptService

function remoteFunction.OnServerInvoke(player, question, answer)
    if the answer is the correct response to the question then
        return true
    else
        return false
    end
end
Ad

Answer this question