Riddle me this obstacle

Include a standalone, bare-bones rbxl file with only the code you want reviewed.

robloxapp-20230219-0002165.wmv (3.1 MB)

Provide an overview of:

  • What does the code do and what are you not satisfied with?
    • As per video I want it so when a player enters the answer to the riddle the player gets a code
      to the door. Only problem is how would I go about checking the answer to the riddle, I’ve tried using a for loop but im stuck on how to go about it.
  • What potential improvements have you considered?
    • Is there another way to generate the random riddle I feel there’s a better way to do it, but it works so if there’s not im cool with it.
  • How (specifically) do you want to improve the code?
    • To confirm the answer with the question presented.
local Players = game:GetService("Players")
local player  = Players.LocalPlayer
local playerGui = player.PlayerGui

local startFrame = script.Parent.StartFrame
local QuestionFrame = script.Parent.QuestionFrame
local QuestionBox = QuestionFrame.QuestionBox
local startButton = startFrame.Start
local TextBoxBackground = playerGui.AnswerTextBox.TextBackGround
local textBox = TextBoxBackground.TextBox
TextBoxBackground.Position = UDim2.new(0.8,0,1.1,0)
local answerBoxActive = UDim2.new(0.8,0,0.8,0)
local CLOSE_Deactivate = UDim2.new(0.8,0,1.1,0)

 ^^^ All those are variables
local status = game.ReplicatedStorage:WaitForChild("Status")

local Riddles = {
	"What goes up and never comes down?", 
	"If you drop a yellow hat in the Red Sea, What does it become?",
	"If you drop me, I’m sure to crack, but smile at me and I’ll smile back. What am I?",
	"What is yours but used by others?"}

local answer = {
	"Age",
	"Wet",
	"Mirror",
	"Name"
}

-- This the start button on the Display Board
startButton.MouseButton1Click:Connect(function()
	startFrame.Visible = false
	QuestionFrame.Visible = true
	 -- This line Brings up the answer box
	TextBoxBackground:TweenPosition(answerBoxActive, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine)
	-- This loop through riddles, selects a random riddle, and sets it to the question on board
	for i = 1, #Riddles do
		local ranDomRiddle = math.random(1, #Riddles)
		QuestionBox.Text = Riddles[ranDomRiddle]
		for j = 1, #answer do
		
		end
	end
	
end)

I think it’s probably impossible to check for different answers taht have the same meaning unless you list all of them, I think you would also need something like Google, taht if you write something worng it wil automatically correct it, but I dot know how to do that sorry

1 Like

Thank you for trying. I Think I figured it out.

1 Like

Hai were you able to do that?

I created a different check system by pairing it with a submit button, that when the answer and the button is pressed it checks the answer with the current question.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.