The code shown by @Sarchyx is not vulnerable to any particular problems. Exploiters are able to tell the server that they pressed a key, but that should not be a vulnerability in and of itself.
It works, however the code is running twice, since it prints twice.
If the person can press the key itself, and the same would happen than using an exploit just to press a key, then it isn’t vulnerable
ContextActionService fires the callback function multiple times during different steps of the input. You have to differentiate between press and release as detailed in the article (see the bottom code example where they check the input state for Begin).
I see, but I’m sure it’s fine since It’s a bool value and it only changes its value once.
You’d be correct that in this case it firing twice is no problem. However, for code correctness, it’s best to make sure you’re only firing the event on key press instead of release.
Well, it fires twice since it starts and it ends, if you only want it to fire once do this:
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild(put the name of the remote even here);
local ContextActionService = game:GetService("ContextActionService");
ContextActionService:BindAction("PressedWaveButton", function(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
remoteEvent:FireServer()
end
end, true, Enum.KeyCode. key code here);