I have a script that does what I need it to, however after it executes once, I need it to be disabled for the person that ran the script. Does anyone have any examples or reference links for a starting point?
✓ ANSWER ACCEPTED
Where do I start with disabling a script for the localplayer?
1 answer
✓ Accepted answer
I was able to get some help on this on the Roblox Discord.
Essentially, what you need to do to get it working is have the block have a detector to detect what is touching it and who is touching it. Also add a delay to the top.
Script 1: (ServerScript)
--Ensure this is the child of the part you want to detect
local part = script.Parent -- Part the will activate when touched
local last = 0
local delay = 1000 --in seconds
part.Touched:Connect(function(hit)
if tick() - last > delay then
last = tick()
if hit.Parent:FindFirstChildOfClass("Humanoid") ~= nil then -- If there is a humanoid in the parent of what touched the part
local char = hit.Parent -- The Character of the player
--if the arm touches it, hit is the arm and parent is the arm's parent
local player = game.Players:GetPlayerFromCharacter(char) -- This gets the player in game.Players by getting the name from its character
local playergui = player.PlayerGui --Where all gui are located into the player
local gui = playergui.ScreenGui.ProgressBar.Config.Progress
gui.Value = gui.Value + 0.005 -- Adds 0.005 to the value
end
end
end)
Script 2, to disable it: (LocalScript)
--Ensure this is is the child of the same script as above. You should also add a detector to ensure it's only being disabled when the parent part is touched.
local progressScript = script.Parent.Script
progressScript.Disabled = true
wait(600)
progressScript.Disabled = false
3 comments
0
Glad you got it working!
0
Instead of tick() - last > delay, there's another way to do it, I'll edit your answer to show you that
0
I made an edit by adding a comment to one of the scripts but it removed yours, could you re-add it?
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
what is the context?
script.Disabled = false will disable your script, but maybe we want to do something else
A little background: This is a progress script (in the normal script) that adds about 0.005 every time a part is touched, however if the player touches the part more than once, it will add more than that. I want to prevent this by disabling the script, however the script should be enabled once again after the round is over.
Can I see the code so far? We don't need to disable the script, more add something called a debounce .
I was able to get it working, I will post an answer to this thread.