userInputService:SimulateUserInput(Enum.UserInputType.MouseButton2)
is there a possible way for the IDEA of this to work? like could i just make a function
SimulateUserInput(Enum.UserInputType.MouseButton2)
Is it possible? and if so how?
userInputService:SimulateUserInput(Enum.UserInputType.MouseButton2)
is there a possible way for the IDEA of this to work? like could i just make a function
SimulateUserInput(Enum.UserInputType.MouseButton2)
Is it possible? and if so how?
There doesnāt appear to be a way on Roblox to do this. What were your plans for using something like this?
Itās not really possible in the way that you are imagining.
What is the scenario of use here?
You can do this easily by using functions!
local function onMousePress()
-- TODO: Code
end
userInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
onMousePress()
end
end)
Now, you can call onMousePress
whenever you want to āsimulateā a mouse press. Thereās better ways of doing this, but this is a very simple example.
There is no deliberate way of doing that however whenever you use UserInputService you can just call a function associated with that key and have all logic there and when you want to āsimulateā a key press you can just call the function.
Ah yes, mocking things.
I remember trying to do something similar in other languages like C#; normally we would just make an interface and then the implementation. When we needed anything, we would take the interface.
This allows us to then make a āmockā implementation and simply control the returns of the implementation without actually doing anything. It should be fairly simple to do this in Luau; you just need to properly define the āContractā (aka Interface) to abide by, and when you donāt need to use it, use the real implementation instead of your class.
I hope this helps you, somewhat.