I'm making a tool where you press '1' to shoot. I am currently stuck with finding out how I could get the mouse's position without using the Button1Down event. Please tell me if there is a function or event that could help me. --connor12260311
✓ ANSWER ACCEPTED
How could I get where the player's mouse is in the 3d world without the Button1Down Evevnt?
1 answer
✓ Accepted answer
You provided bad detail.
You can only get the mouse of a player in a Local Script.
-- Local Script In StarterPack
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
Make sure the Local Script's in a place that it will work.
Now you can get the CFrame of the mouse anytime you want with mouse.Hit. Example,
-- Local Script In StarterPack
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
wait(5)
local cframe = mouse.Hit
There's also a mouse move event that you can use to always tell where the player's mouse is.
-- Local Script In StarterPack
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
mouse.Move:connect(function()
local cframe = mouse.Hit
end)
Here's a link to the wiki for more events of the mouse.
Good Luck
This discussion is preserved as it was. New answers, comments, and votes are closed.
