Scripters! How do I add multiple answers so it unlocks the door?

Hello devs,

Currently I am working on an unoriginal game with my friend, since we wanted to play around studio because we’re both beginners.

The game is basically about guessing the character, so we’ve took a free model of the door we wanted to use for the game. It was already scripted, I could understand part if the script but not fully comprehend.

It only allows one answer, so does anyone know how to add multiple answers? Our objective is to make the game suitable for anyone, that’s why we want to include other languages besides from english.

We’d be grateful if there was any kind of help :blush: !

In the image below, there’s only one answer (value inside StringValue) for Donald Duck, but we wanted to add more values in.

Hello to you too!

You can use some if statements to check if the msg equals your answers.

local Door = script.Parent -- The door
local function openDoor() -- The function that opens and closes the door
    Door.CanCollide = false
    Door.Transparency = 0.7
    Door.CanCollide = true
    Door.Transparency = 0

game.Players.PlayerAdded:Connect(function(player) -- Event that fires when a player joins
    player.Chatted:Connect(function(msg, recipient) -- Event that fires when a player sends a message to the chat
        if msg == script.Parent.TheCharacter.Value then -- The If statement that checks if the message that has been sent equals to the value inside the TheCharacter StringValue Instance
            openDoor() -- Calls the function that opens the door

You can add more if statements for more values if you’d like to.
Or you can use a table that has all the values and a for loop that loops through that table to check if the message equals a value inside that table.

1 Like

the code works but its outdate inside what you want to do
i make a little code for that

local characterFolder = nil -- change the it for da location of your folder (the parts requires be named by numbers)
local characterInfoData = {
[1] = {"a","b","c"}, -- the multiple answers
[2] = {"sus","j"}

local localplayer = game.Players.LocalPlayer
local mycurrentquestion = 0;

function update()
for i,v in pairs(characterFolder:GetChildren()) do
if v:IsA("BasePart") then
local boolean = (tonumber(v.Name) < mycurrentquestion)
local t = table.find({false,true},boolean)-1
local transparency = 0 + (0.7*t)

v.CanCollide = boolean;
v.Transparency = transparency;

function checkchatted(message, recipient)
local found = table.find(characterInfoData[mycurrentquestion],string.lower(message))

if found then
mycurrentquestion += 1 --goes to the next point


--NOTE: you need insert it on PlayerGui
1 Like