I am trying to make my plugin “deactivate” when the “X” key is pressed. I am re-doing my code from a long time ago that has this error. The strange thing is, it works. When I press X it closes the plugin.
I imagine it is from these lines:
function off ()
if game.CoreGui:FindFirstChild("PluginGui") then --remove GUI
game.CoreGui:FindFirstChild("PluginGui"):Destroy()
end
button:SetActive(false)
plugin:Deactivate()
for i = 0, #getDistance do
table.remove(getDistance, i)
end
end
function onX(actionName, userInputState, inputObject) --X
if userInputState == Enum.UserInputState.Begin then
off()
end
end
game.ContextActionService:BindAction("keyPress", onX, false, Enum.KeyCode.X)
Can plugins take local scripts like they do normal scripts? If not, is there a way to avoid this issue? I could maybe use Mouse but it’s deprecated. Is there a better option?