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!
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)
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)
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!