Why function works fine in game scripts, but not in plugin ones?

mouseInputConnection = userInputService.InputChanged:Connect(function(inputObject)
	print("Input began") -- NOT PRINTING WHEN MOUSE MOVED, BUT FUNCTION CONNECTED!
	if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
		print("Mouse moved - smth will occur")
		local PosX = Mouse.X
		local MinimalValue = 4
		local MaximalValue = 1024
		if MinimalValue < MaximalValue then
			ScrollerButton.Position = UDim2.new(math.round(math.clamp((PosX - Offset) / ScrollerFrame.AbsoluteSize.X, 0, 1) * (MaximalValue - MinimalValue)) / (MaximalValue - MinimalValue), 0, 0.5, 0)
		else
			ScrollerButton.Position = UDim2.new(math.round(math.clamp((PosX - Offset) / ScrollerFrame.AbsoluteSize.X, 0, 1) * (MinimalValue - MaximalValue)) / (MinimalValue - MaximalValue), 0, 0.5, 0)
		end	
		TextInput.Text = tostring(math.round((math.clamp((PosX - Offset) / ScrollerFrame.AbsoluteSize.X, 0, 1) * (MaximalValue - MinimalValue)) + MinimalValue))
		Result = math.round((math.clamp((PosX - Offset) / ScrollerFrame.AbsoluteSize.X, 0, 1) * (MaximalValue - MinimalValue)) + MinimalValue)
	end
end)

Why this connection not work on plugins, but working perfect in games? (Basically function which allows you making scrollers:
image

You should use PluginMouse instead as IIRC user input service doesn’t work with mouse events in plugins:
https://developer.roblox.com/en-us/api-reference/class/PluginMouse

1 Like

I already tried using plugin:GetMouse(), and my plugin is plugin:Activate(true). Everything work well, but not Mouse.Move(), which not firing at all, but only if mouse moved in World viewport.