How do I make a quiz door (the same one as guess the logo/quiz games, where you type something in chat, and if it is correct the door becomes 0.5 transparent and uncancollide for a specific period of time), but I wanted to make it so that it can have multiple answers as a correct answer and also make it so that it doesn’t matter if its lower case or upper case, how do I make such thing?
1 Like
I believe something like this would work:
local door = --reference the door
local delay = 1 --time before closing/becoming fully visible and collidable
local answers = {
"answer1",
}
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if table.find(answers, msg:lower()) then
door.Transparency = 0.5
door.CanCollide = false
task.wait(delay)
door.Transparency = 0
door.CanCollide = true
end
end)
end)
You could also do this if you wanted more than one door in a script:
local doors = {
{
door = --reference door
delay = --delay
answers = {
--answers
}
},
{
door = --reference door
delay = --delay
answers = {
--answers
}
},
}
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
for i,v in pairs(doors)
if table.find(v.answers, msg:lower()) then
v.door.Transparency = 0.5
v.door.CanCollide = false
task.wait(v.delay)
v.door.Transparency = 0
v.door.CanCollide = true
end
end
end)
end)
2 Likes
Thank you so much! Just making sure, the delay time is in minutes am I correct?
No, delayed time is in seconds
1 Like
As Azul said, the delay time is in seconds.
1 Like
It means the syntax you’ve written is incorrect. The compiler sees this:
local door = local day = 10
-- ^ doesn't make sense
To fix it, just give the variable a value:
local door = workspace.Door -- or something like this
1 Like
I would actually change the local answers bit to something like…
This is just an example, don’t actually copy and paste considering I most likely made an error in it. c:
plr.messaged:Connect:function(msg)
if msg:lower == "an answer here" then
-- rest of the script if its right
end
end)
1 Like