I’m making a code entry system in the form of a gui for my puzzle/story game, and I’m running in to an interesting bug.
For whatever reason, the script only says the code is correct on the second time you enter it.
I can’t find any glaring mistake, and the code is relatively simple so it should be working.
local RE = game.ReplicatedStorage.remoteEvents["Story I"]["Level 1"].electrical
local closeButton = script.Parent.close
local confirmButton = script.Parent.confirm
local codeEntry = script.Parent.codeEntry
local Frame = script.Parent
local player = game.Players.LocalPlayer
local TS = game:GetService("TweenService")
function open()
local bTween = TS:Create(game.Lighting.Blur, TweenInfo.new(.3), {Size = 20}):Play()
Frame.Visible = true
end
RE.OnClientEvent:Connect(function(input)
if input == "open" then
open()
end
end)
closeButton.MouseButton1Click:Connect(function()
Frame.Visible = false
local bTween = TS:Create(game.Lighting.Blur, TweenInfo.new(.3), {Size = 0}):Play()
RE:FireServer("closed")
end)
confirmButton.MouseButton1Click:Connect(function()
-- this is where I believe the issue would be...
if codeEntry.Text == workspace["Story I"]["Level 1"].answerButton.code.Value then
Frame.Visible = false
TS:Create(game.Lighting.Blur, TweenInfo.new(.3), {Size = 0}):Play()
RE:FireServer("foundCode")
else
codeEntry.Text = "Incorrect"
wait(.7)
codeEntry.Text = ""
end
end)
Here is a video of what I mean. Note, the demo code is “123”.
(it’s an unlisted YT vid)
Any help is greatly appreciated!