Gui turning visible

So what is happening is when i click the invisible part the gui shows up and once you get the code wrong, it turns invisible but when you try to click it again it doesn’t go visible again.

image

[Local Script] (inside the textbox)

script.Parent.FocusLost:Connect(function(enterPressed)
	local code = script.Parent.Text:lower()
	if enterPressed and code == "copper" then
		script.Parent.TextColor3 = Color3.new(0.34902, 1, 0)
		script.Parent.Text = "Access Granted"
		script.Parent.TextEditable = false
		wait(2)
		script.Parent.Parent.Visible = false
		script.Parent.TextColor3 = Color3.new(0,0,0)
		script.Parent.Text = ""
		script.Parent.TextEditable = true
	end
	if enterPressed and code ~= "copper" then
		script.Parent.TextColor3 = Color3.new(1, 0, 0.0156863)
		script.Parent.Text = "Access Denied"
		script.Parent.TextEditable = false
		wait(2)
		script.Parent.Parent.Visible = false
		script.Parent.TextColor3 = Color3.new(0,0,0)
		script.Parent.Text = ""
		script.Parent.TextEditable = true
	end
end)

image

[Server Script] (inside the invisible part)

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	plr.PlayerGui.coppersand.Frame.Visible = true
end)

Well, I’m not too sure what the problem here is but I think that since the ClickDetector script is unnecessarily in a Script and not a LocalScript, and that the TextBox’s script is a LocalScript, that the property will not replicate. Change the Script by the ClickDetector to be a LocalScript. You should place it in ReplicatedFirst.

when i make it into a local script and put it into replicatedfirst it says invisiblepart is not a valid member of workspace and when i put it into replicated storage, there are no errors but when i click the part nothing happens

Which brings me to things all new developers forget: the delay.

LocalScripts require a wait statment, waiting 2 seconds allows the client to load. So put wait(2) as the first line of the script.

im not a new devleoper, and its an event, so it fires whenever they press enter on the gui, so your wrong.

Hm. I’m quite confused on what you just said, but I have a limited amount of posts every day so I’ll try to make this one long enough to also understand.

Me neither.

Ok, how does this relate to the topic?

I’m assuming you listen to FocusLost.

But this is not what I’m talking about. I’m talking about the “Server Script inside the invisible part”. You convert it to local and, since it doesn’t need anything outside of the current player, it shouldn’t matter to place the code in a LocalScript, but you must add a wait(2) statement, manually place the path out instead of script.Parent, and finally, place it in ReplicatedFirst or something in StarterPlayer. You can also place it in StarterPack but I don’t recommend that, since the script will reset every time the player dies.

[spoiler]Coming back to the event thing, I believe that works. Good job on coding that (wherever it is since it’s not listed).[/spoiler]

bro are you seriously mad that i said your wrong so wrote a whole paragraph? im doing it my own way because i don’t userstand you nor need your help also why do you have a limited amout of posts? its not like your famous or something

I didn’t write a paragraph, and I’m not mad, I am just a little confused on why my previous post didn’t work for you, because you didn’t provide many useful details that I could understand.

[spoiler]
Alright, it might’ve seemed like a paragraph, but that’s just because of all the quotes from your text I made.
[/spoiler]

So, since I answer people’s questions, I’ll put it simply.

Ok, this is because the Client (the LocalScript) loads faster than the InvisiblePart that you made. So here’s your assumed LocalScript:

wait(2)
workspace.invisiblepart.ClickDetector.MouseClick:Connect(function(plr)
	plr.PlayerGui.coppersand.Frame.Visible = true
end)

Edit: Whoops forgot pressing Shift+Enter posts quickly!

Odd … think it had something to do with the focus idk.

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	plr.PlayerGui.coppersand.Frame.Visible = false
	plr.PlayerGui.coppersand.Frame.Visible = true
end)

The local script …

script.Parent.FocusLost:Connect(function(enterPressed)
	local code = script.Parent.Text:lower()
	if enterPressed and code == "copper" then
		script.Parent.TextColor3 = Color3.fromRGB(0, 200, 0)
		script.Parent.Text = " Access Granted "
	else
		script.Parent.TextColor3 = Color3.fromRGB(200, 0, 0)
		script.Parent.Text = " Access Denied "
	end	script.Parent.TextEditable = false wait(2)
	script.Parent.Parent.Visible = false
	script.Parent.TextColor3 = Color3.new(0, 0, 0)
	script.Parent.Text = ""
	script.Parent.TextEditable = true
end)

Well I don’t know what to say. Clearly something I haven’t researched. Tested it on PC and Mobile it seems to work well on both. It’s tight and it’s working … If you look at the Frame when active on the screen it’s says it’s not visible. :eyes:

Hello there, I don’t know if you already got a variable for FocusLost, but something is missing.
For example if ‘FocusLost’ Is an event, then you should type:

script.Parent.FocusLost.OnServerEvent:Connect(function(enterPressed))

if it’s a TextButton then you should put:

script.Parent.FocusLost.MouseButton1Click(Connect(function(enterPressed))).

You need to specify the event that happens on ‘FocusLost’.
Maybe that’s the problem.