So I made a math question GUI and if you get it right it prints correct and if you get it wrong it prints wrong. I answer the questions correctly but the game is telling me it’s wrong.
local Player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local QuestionText = script.Parent.QuestionUI.Question
local function newQuestion()
local firstArgument = math.floor(math.random(1, 10))
local secondArgument = math.floor(math.random(1, 10))
QuestionText.Text = firstArgument.." ".."+".." "..secondArgument.." ".."="
return firstArgument + secondArgument
end
local function startCountdown()
local answer = newQuestion()
print(answer)
local guiInfo = TweenInfo.new(
10,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In,
0,
false
)
local props = {
Size = UDim2.new(0, 5,0, 6);
}
local tween = tweenService:Create(script.Parent.QuestionUI.Countdown, guiInfo, props)
tween:Play()
tween.Completed:Wait()
local Answer = script.Parent.QuestionUI.Answer.Text:gsub("%s","")
if #Answer == 0 then
print("no answer")
elseif #Answer > 0 then
if Answer == answer then
print(Answer)
print("correct")
else
print(Answer)
print("wrong")
end
end
end
task.wait(2)
script.Parent.QuestionUI:TweenPosition(UDim2.new(0.362, 0,0.688, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 0.5, true)
task.wait(0.5)
startCountdown()