Is there a way to get the mouse's size?

Been looking around for a while now and haven’t fell on anything useful.

Seen something say it’s 64x64 but it wouldn’t resolve properly on different screens.

1 Like

Hi, @uhi_o. This wiki link explains the default size of the Mouse.Icon which is:

The default mouse image is 64x64 pixels, with the mouse taking up 17x24 pixels of space.
Source: Mouse | Documentation - Roblox Creator Hub

I don’t think this would be an issue cross-platforms, but if you want: you can make a custom Mouse.Icon.

2 Likes

Would there be a formula you know of to get the size which 17x24 represents on screen?

I don’t think this would be an issue cross-platforms

It is for the genre of my game since it mainly uses the mouse to be played with.

Not entirely sure about any formulas like that.

I also like making games that are heavily surrounded with Mouse input/hovers. Although these features wouldn’t translate naturally, you should be able to have workarounds for other platforms. Such as, when collecting user input you can detect where the user is on a mobile device, PC, xbox, etc.

(This can be done with the following example from the wiki):

-- A sample function providing multiple usage cases for various types of user input
UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		local keyPressed = input.KeyCode
		print("A key is being pushed down! Key:",input.KeyCode)
	elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("The left mouse button has been pressed down at",input.Position)
	elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
		print("The right mouse button has been pressed down at",input.Position)
	elseif input.UserInputType == Enum.UserInputType.Touch then
		print("A touchscreen input has started at",input.Position)
	elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
		print("A button is being pressed on a gamepad! Button:",input.KeyCode)
	end
 
	if gameProcessed then
		print("\tThe game engine internally observed this input!")
	else
		print("\tThe game engine did not internally observe this input!")
	end
end)

Source: UserInputService | Documentation - Roblox Creator Hub

BTW, I’m not sure if this is what you are looking for, but this is how I would handle cross-platform inputs.

My game is only for users with mouse and keyboard.
Would there be a way to detect pen tablet?

Not sure that would be any different than detecting a Touch input.

But since you said:

You can just only allow PC users in your game.
To do this:

image

Make sure all of these are unchecked.

image

1 Like

Hope this helped, if so make sure to mark the answer! If not, let me know if I can help more. :slight_smile:

Didn’t really get the answer I expected, but I ended up creating a new mouse system.

1 Like

I gotcha, so you want:

and

Taking the code from earlier:

-- In order to use the InputBegan event, the UserInputService service must be used
local UserInputService = game:GetService("UserInputService")
 
-- A sample function providing multiple usage cases for various types of user input
UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		local keyPressed = input.KeyCode
		print("A key is being pushed down! Key:",input.KeyCode)
	elseif input.UserInputType == Enum.UserInputType.Touch then
		print("A touchscreen input has started at",input.Position) --<<< here
	end
end)

You can get the input.Position (of the Touch) on like a mobile device, touch screen PC, etc. Could you use this to detect what you are trying to do? Because on a mobile device there is no Mouse, so you would need to improvise.