Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gui only works the first time but when I close it, it doesn't work?

I am trying to make a game that when I click a part i can interact with it. My script works the first time but when I close it and click the part again, it doesn't appear. And of course I already have a ClickDetector inside the Part. I would love if you can help me, thank you.

The script inside the Part:

script.Parent.ClickDetector.MouseClick:Connect(function(click)
	click.PlayerGui.Talk.TextLabel.Visible = true
	click.PlayerGui.Talk.TextLabel.Text = tostring(script.Parent.dialogs.dialog1.Value)
end)

the script in the close button:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible = false
end)

1 answer

✓ Accepted answer

Is your 'close button' script a local script? I'm certain the issue is that you're setting the TextLabel's visibility to true on the server and setting it to false on the client, and because of filtering enabled (which stops the client from making modifications to the server), the visibility of the TextLabel will remain true on the server, and setting it to false on the client won't actually change it on the server, only your client. Which is why it won't show up again when you click the ClickDetector, because it's still true on the server.

To fix this, you'll need to change both scripts to be the same type (either local script or server script). You could change either one. If you're changing them both to be a local script then you'll need to change the location of the script in the part (as local scripts don't actually work in workspace) you'll need to move it somewhere else like StarterGui for example. You can see all the locations where local scripts will work here

This discussion is preserved as it was. New answers, comments, and votes are closed.