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

How can I get a mouse's position on click?

Asked by
Mystdar 352 Moderation Voter
8 years ago

Would I use the humanoid's target point?

Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
Character = Player:GetPlayerfromCharacter()

function DownClick()
    print (Character.Humanoid.TargetPoint)
end
mouse.Button1Down:connect(DownClick)
1
Do you mean it's 2D position on screen or where it's pointing in the 3D world? If it's the former, use the X and Y properties of the mouse, otherwise use the Hit or Origin properties of the mouse. X and Y are int values while Hit and Origin are CFrame values. Spongocardo 1991 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Local Script

repeat wait() until game.Players.LocalPlayer.Character
local player = game.Players.LocalPlayer
local mouse = Played:GetMouse()

function onclick()
if mouse.Hit~=nil then
print(mouse.Hit)--CFrame Value of mouse position
print(mouse.Hit.p)--Value of CFrame that gives Vector3 Counterpart
end
end

mouse.Button1Down:connect(onclick)
Ad

Answer this question