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.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
print(Mouse.X, Mouse.Y)
local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Input, GPE)
        if GPE then return end
        print(Input.Position.X, Input.Position.Y)
end)

UserInputService.InputChanged:Connect(function(Input, GPE)
        if GPE then return end
        print(Input.Position.X, Input.Position.Y)
end)

UserInputService.InputEnded:Connect(function(Input, GPE)
        if GPE then return end
        print(Input.Position.X, Input.Position.Y)
end)

Ad

Answer this question