I am trying to make a function, that when the player hits a keyboard hotkey, (example: R-key), the game will detect the location of the closest on-surface position in the exact direction where the player’s mouse is pointed, but I have no clue what function I would use for that detection, can anyone help?
I noticed, mouse.hit will give me the exact location of the mouse in the workspace, is it possible for me to save that location to a local and then create a part on that location?
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local TransferPartEvent = ReplicatedStorage:WaitForChild(“TransferPartEvent”)
local tool = script.Parent
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
print(“Button1Down”)
local Location = mouse.Hit.p
TransferPartEvent:FireServer(Location)
end)