So I’m working on a new game and i made a gui button to disable an other running script, by clicking it.
it marks the script as disabled, but the script won’t stop. i need a urgent help please.
here’s the code
(Keep in mind i’m not a scripting professional i’m just a noob so yea don’t judge me about the bad coding skills ;()
local ScreenGui = script.Parent
local TextButton = ScreenGui.TextButton
TextButton.MouseButton1Up:Connect(function()
game.StarterGui.Main.LocalScript.Disabled = true
wait()
end
I don’t know. Maybe you should try look for the answer? Is it that hard to search up your problem into your bowser that you have to make a whole new thread? Only if you can’t find the answer anywhere then you should make a thread but there is no reason to make a post when there are plenty of answers on the internet…
Im helping you because i’m redirecting you to a thread that had been made to answer your question. Just because you are lazy and can’t look up your issue on the internet its not my problem.
You’d also want to make sure that ResetOnSpawn is set to false on the Main gui so it won’t reset when the player respawns, unless that’s desired behaviour.
Avoid disabling scripts if you can. There is always going to be a better option available to you that involves properly cleaning up your code and objects. Disabled should scarcely or never be used in production code. What kind of script are you trying to disable?
Are you not able to add a condition or event of some kind instead that tells the script to change a boolean variable in your generator script? Assuming that you’re using a loop of some kind to generate parts, you can read this boolean for your condition and stop the loop if it’s true (or some other thing you expect).
Imagine this scenario: in a while loop, the body of the loop generates a single part.
local haltGeneration = true
-- Assume a BindableEvent exists somewhere
ExternalHaltGeneration.Event:Connect(function ()
haltGeneration = true
end)
local function startGeneration()
haltGeneration = false
while not haltGeneration do
-- Generate one part
end
end
Then from your button script, you can call Fire on that ExternalHaltGeneration event to flip the condition which in turn stops generation. No involvement of Disabled plus the benefit of an event-based approach. Using break, by the way, also works, especially in for loops.
someone already solved my problem thanks for the help, but the other issue i’m facing is
I made a script inside a “reset” button which supposed to remove All parts named “lags” that have been found in workspace when someone clicks it, but it removes one by one each time you click, and not everything, Is there a solution for this? ;(