Do plugins work well in LocalScripts?

Hi devs,

I’m currently making a plugin, and I’m wondering if it’s fine to use LocalScripts, because I need to use UserInputService. I know that it’s possible to use them, but is it optimal?

1 Like

Plugins run under the same “Plugin” context regardless of the type of script they’re contained in.

The only seamless way to implement plugin inputs is using the old PluginMouse.KeyDown event which is deprecated but its all we have

It doesn’t even send InputObjects, only the numeric value of the input, which is mapped to Enum.KeyCode thankfully

local mouse = plugin:GetMouse()
local ESCAPE_KEYCODE = Enum.KeyCode.Escape.Value

mouse.KeyDown:Connect(function(k)
  if string.byte(k) == ESCAPE_KEY_CODE then
    print("escape was pressed")
  end
end)

plugin:Activate(true) -- enable with mouse object
1 Like

Hi there,

When I use plugin:Activate(true), it seems to disable the mouse, and all mouse events.
Are you aware of any ways to fix this, while still being able to be used in a plugin widget?

Thanks

EDIT: I think I’ve managed to finally find a solution. Thanks for the help keyboard inputs, though.