✓ Accepted answer
So before we get into how to solve your problem, let's just quickly go over what you have here, right?
You can't get the Local Player from a Server Script
You can't get the Mouse from a Server Script
You tried to move the part by changing it's Velocity
mouse.Hit.p is a Vector3 value, so you don't need to put it inside of another Vector3 value
How to fix this
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = Instance.new("Part")
part.Parent = workspace
part.Anchored = true
mouse.TargetFilter = part
mouse.Button1Down:connect(function()
part.Position = mouse.Hit.p
end)
I'm not sure exactly what you're going for, but if you wanted everyone to be able to see this part, you could fire the server with a remote event on click, and you can pass in the part's position as the argument.
Link on Remote Events/Functions
EDIT
I misunderstood the question apparently, so i'll just leave this here.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = script.Parent
local startPoint = part.CFrame.p
local speed = 100
mouse.Button1Down:connect(function()
local lookPoint = mouse.Hit.p
local projectile = Instance.new("Part")
projectile.Parent = workspace
projectile.CFrame = CFrame.new(startPoint,lookPoint)
mouse.TargetFilter = projectile
local BV = Instance.new("BodyVelocity")
BV.Parent = projectile
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = projectile.CFrame.lookVector * speed
end)
The rest of the work is up to you, that means utilizing RemoteEvents.
4 comments
Why change the part's Velocity instead of Position?
If you want the part to move towards the mouse cursor use "(part.Position-mousePos.P).unit*speedInStudsPerSecond" as the velocity (you might need to make it negative)... If you want the part to teleport to the cursor use "part.Position = mousePos.P"... Also mousePos.P is already a Vector3... You are getting the position component of a CFrame value (mouse.Hit).
I do want it to move towards the mouse position not teleport. Also I tried using what you gave me it still won't work.
Edited my answer.