You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to learn how to if there is a way to stop a remote function from running.
What is the issue? Include screenshots / videos if possible!
The Issue is that in the code that I’m writing requires a function that stops a remote function from running.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t tried any solutions as of now. I haven’t looked at solutions on the Developer Hub.
Here is the code.
-- local rs = game:GetService("ReplicatedStorage")
local cfr = rs:WaitForChild("Clicker")
local scfr = rs:WaitForChild("SuperClicker")
local trm = rs:WaitForChild("RemoteEvent")
local d = false
local cd = 3
cfr.OnServerInvoke = function(p)
if d == false then
p.leaderstats.Taps.Value += 1
if p.leaderstats.Rebirths.Value > 0 then
p.leaderstats.Taps.Value += p.leaderstats.Rebirths.Value
wait(p.leaderstats.Upgrades.ClickCooldown.Value)
d = false
end
end
end
scfr.OnServerInvoke = function(p)
if d == false then
d = true
p.leaderstats.Taps.Value += 50 * (p.leaderstats.Rebirths.Value + 1)
wait(2)
d = false
return true
end
end
What you’re doing is almost on the right track, but look
cfr.OnServerInvoke = function(p)
if d == false then
p.leaderstats.Taps.Value += 1
if p.leaderstats.Rebirths.Value > 0 then
p.leaderstats.Taps.Value += p.leaderstats.Rebirths.Value
wait(p.leaderstats.Upgrades.ClickCooldown.Value)
d = false
end
end
end
You checked if d is false, then continue the code, but at the end of the code, you set the value of d to false. Which doesn’t change anything. Try setting it to true.
Also, you haven’t specified what the trigger will be for stopping the remote function from running. Like do you want to only have the remote function run once? or is there any other condition?
local d = false
local cd = 3
cfr.OnServerInvoke = function(p)
if not d then
d = true
p.leaderstats.Taps.Value += 1
if p.leaderstats.Rebirths.Value > 0 then
p.leaderstats.Taps.Value += p.leaderstats.Rebirths.Value
wait(p.leaderstats.Upgrades.ClickCooldown.Value)
end
wait(2)
d = true
end
end
scfr.OnServerInvoke = function(p)
if not d then
d = true
p.leaderstats.Taps.Value += 50 * (p.leaderstats.Rebirths.Value + 1)
wait(2)
d = false
return true
end
end
Are you just trying to fix the debounces? The above achieves that.
I’m not sure why it doesn’t work, but supposed to be like that if you really want it to only run once, so do like I mentioned.
That should stop that remote function from running.
Also, your question isn’t clear enough. There are two remote functions, which one are you trying to stop? If you’re trying to stop only one and for eternity, you should have separate debounce variables for each cfr and scfr Remote Functions.