You can get the player’s mouse in a local script and use remote events to tell the server where to place the part.
Create a remote event in ReplicatedStorage called “PlacePart”
-- LOCAL SCRIPT INSIDE TOOL
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse() -- Gets the player's mouse
local tool = script.Parent
local remoteEvent = game:GetService('ReplicatedStorage'):WaitForChild("PlacePart")
function onActivate() -- Function to run when the player uses the tool
remoteEvent:FireServer(mouse.Hit.Position) -- Gives the server the player's targetted part and mouse position
end
tool.Activated:Connect(onActivate)
-- SCRIPT INSIDE SERVERSCRIPTSERVICE
local remoteEvent = game:GetService('ReplicatedStorage'):WaitForChild("PlacePart")
function onEvent(player, position) -- stores the information send from the client in 2 variables
local part = Instance.new("Part") -- creates the part
part.Position = position -- moves the part to the position send from the client
part.Parent = workspace -- puts the part in the workspace
end
remoteEvent.OnServerEvent:Connect(onEvent)
If you have any questions or errors feel free to ask me
-- LOCAL SCRIPT INSIDE TOOL
function onActivate()
if mouse.Target.Name == "Part" then -- Change this if statement to whatever you're checking for
remoteEvent:FireServer(mouse.Hit.Position)
end
end