I think I understand what you’re trying to do here.
With the limited patch of code, I’m assuming you’re clicking on the door, and it shows a textbox that you write the password in.
What’s happening is that the moment you click the door it runs this line:
if p.PlayerGui.keygui.Frame.TextBox.Text == text then
That line is checking if what’s written inside the textbox is “sputnik” the same moment you clicked the door.
There’s a couple of ways for you to do this. Instead of instantly checking for the password (which is impossible for you to write in such a short time frame) you could add wait(3) and it’ll check for the password 3 seconds after you clicked the door, for example:
local text = “sputnik”
local d = game.Workspace.banco1
local p = game.Players.LocalPlayer
script.Parent.MouseClick:Connect(function()
p.PlayerGui.keygui.Frame.Visible = true
wait(3)
if p.PlayerGui.keygui.Frame.TextBox.Text == text then
d.CanCollide = false
d.Transparency = 0.7
p.PlayerGui.keygui.Frame.Visible = false
wait(10)
d.CanCollide = true
d.Transparency = 0
end
end)
OR
Instead of running all the code at the same time, you could add a button that reads what you wrote inside the textbox, for this you’d have inserted a button inside your GUI. Example code:
local text = “sputnik”
local d = game.Workspace.banco1
local p = game.Players.LocalPlayer
script.Parent.MouseClick:Connect(function()
p.PlayerGui.keygui.Frame.Visible = true
p.PlayerGui.keygui.Frame.TextButton.Visible = true
end)
p.PlayerGui.keygui.Frame.TextButton.MouseButton1Click:Connect(function())
if p.PlayerGui.keygui.Frame.TextBox.Text == text then
d.CanCollide = false
d.Transparency = 0.7
p.PlayerGui.keygui.Frame.Visible = false
p.PlayerGui.keygui.Frame.TextButton.Visible = false
wait(10)
d.CanCollide = true
d.Transparency = 0
end
end)
This kind of a long post, shoot any question.
EDIT: Forgot to mention that if you only run the code in a localscript, the “door” will only open for the player that put the password correctly and not the entire server, since localscripts don’t replicate to the server unless you use remoteFunctions.