Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Efficient ways to Gui?

Asked by
Vawx 10
9 years ago

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.

0
It depends on what you're trying to do. Perci1 4988 — 9y
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. Vawx 10 — 9y
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. Perci1 4988 — 9y

1 answer

Log in to vote
1
Answered by
Validark 1580 Snack Break Moderation Voter
9 years ago

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

0
I don't take credit for the answer, I just gave example code. Validark 1580 — 9y
0
Thank you. Vawx 10 — 9y
Ad

Answer this question