local disabled = true
local FireMagic = game.ReplicatedStorage.Activations:WaitForChild("FireMagic")
FireMagic.OnClientEvent:Connect(function()
disabled = false
print("fired")
end)
if disabled then return end
The print(“fired”) function works which means that disabled is set to false, but it still prevents the script below it from working.
local disabled = true
local FireMagic = game.ReplicatedStorage.Activations:WaitForChild("FireMagic")
FireMagic.OnClientEvent:Connect(function()
if disabled then
disabled = false
print("fired")
task.wait(2)
disabled = true
end
end)
It seems like you are trying to wait for the fire magic to happen for the code to run. Instead, move the code below the if disabled then return end into the onClientEvent.
local FireMagic = game.ReplicatedStorage.Activations:WaitForChild("FireMagic")
FireMagic.OnClientEvent:Connect(function()
print("fired")
--code here
end)
The script would be written almost the same exact way, just moving some things and adding a few lines.
local debounce = false
local FireMagic = game.ReplicatedStorage.Activations:WaitForChild("FireMagic")
FireMagic.OnClientEvent:Connect(function()
if debounce then return end
debounce = true
task.delay(2, function() --2 represents the wait in seconds
debounce = false --will run this after the wait
end) --Kinda works like task.spawn, doesn't interrupt the code.
print("fired")
--code here
end)