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

How do I tell a localscript inside of a GUI to run another when finished?

Asked by 4 years ago

I have a button GUI hooked up to a localscript, and when its clicked I want it to tell another local script inside of the player to "turn on" I guess. Whats the best way to do this?

I was thinking of putting a value inside of the player and when its changed, it will fire the other localscript.

I also thought of putting a remote event inside of the player, but I have no idea if that will even work so I haven't tried it.

Thanks!

3 answers

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

make two scripts one in the button and one in the frame the frame one should be disable

local DisabledS = script.Parent.Parent.DisabledScript
DisabledS.Disabled = true
script.Parent.MouseButton1Click:Connect(function()
DisabledS.Disabled = false
end)
Ad
Log in to vote
0
Answered by 4 years ago

2 local scripts

--LOCAL SCRIPT--


local button = script.Parent.TextButton --change textbutton with the butotn name
local script2 = script.Parent.LocalScript --change localScript to the other script name
local gui = script.Parent

button.MouseButton1Click:Connect(function()
    script2.Disabled = false
    gui.Enabled = false
end)
0
Its this simple are you kidding me? Does it instantly fire the script once it is not disabled anymore? guywithapoo 81 — 4y
0
I'm pretty sure yes. Cookie_clicker2 16 — 4y
Log in to vote
0
Answered by 4 years ago

You should always avoid disabling scripts whenever possible. If you always use disabling scripts as a method to disable certain features, you'll split code that makes sense to all be in the same script into different scripts, which causes problems when you need to sync each feature and when you share values. Also, more scripts typically means more threads, which if you split enough scripts up, this may build up and become an issue.

To replace the need to disable different scripts, you can use a variable to tell something if it should be enabled or not. For example, you can have some code like

local fooEnabled = false

local function foo(...)
    if fooEnabled then
        --stuff
    end
end

event1:Connect(function()
    fooEnabled = not fooEnabled
end)

event2:Connect(foo)

Hope this helps!

Answer this question