Keybinds | Delay Error?

Greetings, I’ve coded some keybindings that allow me to control ParticleEmitters, Beams, Parts and All Via a simple Button press on my keyboard,

It seems the code is 100% fine, but it is quite delayed, by that I mean;

It is supposed to be a 1 click action, meaning it only needs 1 click to execute the code,
but instead, it makes me click 2 times, for some odd reason. (Keep in mind I am not a professional at this)

If there are any solutions to how to fix this, please provide one.

image
SNP2

1 Like

You should provide code snippets as default, so please provide them. We really can’t help you without seeing your code.

Yeah, I realized, ahaha. I was in the middle of snipping some code.image
image

Why do you need to disable the script?

It’s probably where you have:

on = not on

because, on will become the opposite of what it starts with

What do you reckon I should change it to?

Does the variable on start as false or true?

I know this sounds quite mad, but I’m actually not sure.

Use the find results panel and search for either:

local on = true
local on = false
on = true
on = false

Neither of the were recognized.

image

add this to the start of the server side code and see if it works:

local on = false

Could you maybe provide the whole code? Copy and Paste it. So it is easier to Quote it.

Which might that be? (Excuse me for going into this situation blind, I was assisted during the making.

I think that one on line 59…

function script.FireA.OnServerInvoke()

on = not on
if on then

script.FireAO.Disabled = false
else
script.FireAO.Disabled = true
end
end

function script.FireB.OnServerInvoke()

on = not on
if on then

script.FireBO.Disabled = false
else
script.FireBO.Disabled = true
end
end

function script.FireC.OnServerInvoke()

on = not on
if on then

script.FireCO.Disabled = false
else
script.FireCO.Disabled = true
end
end
function script.CO.OnServerInvoke()

on = not on
if on then

script.CO2.Disabled = false
else
script.CO2.Disabled = true
end
end
function script.COO.OnServerInvoke()

on = not on
if on then

script.CO22.Disabled = false
else
script.CO22.Disabled = true
end
end
function script.SPRK.OnServerInvoke()

on = not on
if on then

script.SPK.Disabled = false
else
script.SPK.Disabled = true
end
end
function script.SPRK1.OnServerInvoke()

on = not on
if on then

script.SPK1.Disabled = false
else
script.SPK1.Disabled = true
end
end

Format

Format your code like this.

put that line of code at the start of the script.

Yes you never define on. Put

local on = false;

at the start of the code.

If it works, put solution to Xuefei.

Still doesn’t work, still makes me double click the bind-key, do one of you just want the file for the whole thing to try and fix it?

Try doing local on = true, then.

Still didnt work, want the file?