I need to aim a tool towards where the player clicks.
I have this script here in local
local tool = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
function pew()
wait (.01)
local arrow = script.Parent.needle
arrow.CFrame = CFrame.new(tool.Handle.Position, mouse.Hit.p) --like this, where the tool does something in the direction of your mouse click
end
tool.Activated:connect(pew)
There is a script in server which does the rest but i'm certain it works fine, but i'll provide it anyways.
local tool = script.Parent
local bullet = game.ReplicatedStorage.bullets.needle
local sound = tool.Sound
function pew()
sound:Play()
local arrow = bullet:clone()
arrow.Parent = tool
game:GetService("Debris"):AddItem(arrow, .22)
local v = Instance.new ("BodyVelocity", arrow)
v.velocity = arrow.CFrame.lookVector *90
v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
tool.ManualActivationOnly = true
wait (.3)
tool.ManualActivationOnly = false
end
tool.Activated:connect(pew)
But it only works in studio because of the whole localscript interacting with server objects thing.
Is there a way I could aim the tool using a server script?
I could probably turn off filtering to make it work, but I would like to keep that on since it helps with learning to script good.

3 comments
Consider using RemoteEvents. You could parent the bullet to the character if you wanted.
I don't see how remote events will help? I think I clearly stated the problem was I needed to launch the object in the direction of the mouse click. I'll revise my question to make that more clear though for others
You could do that, but that's a very bad idea. You never want server to handle such client interactions, or the user experience won't be smooth.