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

How to get mouse XYZ when I click with tool and is there better way to check where to fire my spell?

I'm trying to get the player's mouse position in XYZ coordinates so I can send a bullet (spell in this case) in that direction. How do I get the position of where the mouse is clicked or is there a better way of doing what I'm trying to do?

Here's my current code.

local LocalPlayer = game.Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
tool.Activated:Connect(function()
	print(Mouse.Hit.p)
end)

In the developer console when I click and hold my tool, nothing comes up.

1 answer

local LocalPlayer = game.Players.LocalPlayer local Mouse = LocalPlayer:GetMouse() local tool = script.Parent tool.Activated:Connect(function() print(Mouse.Hit.Position) end)

this code will work

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