Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you get the local player's mouse's position in Vector2 value and not in Vector3 value?

Asked by
XDvvvDX 186
4 years ago
Edited 4 years ago

Hey. I'm looking for how to get the local player's mouse position in Vector2 value and not in Vector3. I will make sure to ACCEPT the helpful comment!

1 answer

Log in to vote
1
Answered by
ACHRONlX 255 Moderation Voter
4 years ago

There are many ways you can do this, you can use the Mouse's X and Y properties, or UserInputService.

1local Player = game.Players.LocalPlayer
2local Mouse = Player:GetMouse()
3print(Mouse.X, Mouse.Y)
01local UserInputService = game:GetService("UserInputService")
02 
03UserInputService.InputBegan:Connect(function(Input, GPE)
04        if GPE then return end
05        print(Input.Position.X, Input.Position.Y)
06end)
07 
08UserInputService.InputChanged:Connect(function(Input, GPE)
09        if GPE then return end
10        print(Input.Position.X, Input.Position.Y)
11end)
12 
13UserInputService.InputEnded:Connect(function(Input, GPE)
14        if GPE then return end
15        print(Input.Position.X, Input.Position.Y)
16end)
Ad

Answer this question