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

Efficient ways to Gui?

I've always used that method to activate scripts in PlayerGui by making a BoolValue in Workspace or some other directory and have a script like this (This would be the script inside the PlayerGui).

Frame = script.Parent.Frame
Value = workspace.Value
while wait(.5) do
	if Value.Value == true then
		Frame.Visible = true
	end
end

This isn't efficient, I've seen people control all Gui's with one script in Workspace. I could never figure out how they did it without annoying loops and values. I've been scripting with Lua for about a year now and still haven't figured this out.

3 comments

0

It depends on what you're trying to do.

0

Trying to activate say a Gui in player Gui's to come up on a screen but control it from a script in Workspace.

0

What you have is fine, but you should use a Changed event instead of a while loop. You could also just directly set the GUIs Visible property to the value's Value, without the if statements. If you want it to work with FilteringEnabled, then you could use a RemoteEvent.

1 answer

✓ Accepted answer

As Perci1 suggested, use a changed event to detect the value change, rather than just checking it over and over. He also said to change the Visible property to the same thing as Value's value.

Frame = script.Parent.Frame
Value = workspace.Value

Value.Changed:connect(function()
		Frame.Visible = Value.Value --If Value's Value is true, make it visible. If false, make invisible
end)

An alternative method would be to clone the Gui into the player's PlayerGui. The best way would be to use a RemoteEvent.

Look for "Client Event" on the wiki

2 comments

0

I don't take credit for the answer, I just gave example code.

0

Thank you.

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