Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i get the mouses position so i can set the parts position to it when i left click?

part = Instance.new("Part",game.Workspace)

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function()

end)

1 answer

✓ Accepted answer

You can get the mouse position by getting the MouseObject and using Mouse.Hit.p. There is more information on it here: https://developer.roblox.com/api-reference/property/Mouse/Hit

To check if they left clicked, you would use Mouse.Button1Down event. More documentation here and sample codes: https://developer.roblox.com/api-reference/event/Mouse/Button1Down

However, I recommend using UserInputService as it is more modern and updated. More documentation here and sample codes: https://developer.roblox.com/api-reference/event/UserInputService/InputBegan

6 comments

0

when i print the mouses position, it only prints it once, how would i have it print an updated positions every 3 seconds?

0

The mouse position is already updated. Just call the position every time you click. If you still want it to do that, use a loops and wait().

0

it just prints the same position over and over again

0

even when i move my mouse to a different area

0

Are you sure? It shouldn't work like that, you are probably doing something wrong. Don't store Mouse.Hit, you should be calling Mouse.Hit.p every time for the updated mouse position.

0

ok yea u were right, its working now. thank :)

This discussion is preserved as it was. New answers, comments, and votes are closed.