I was trying to test the best options to visualize a bullet and the first thing I did was use the part’s velocity it works but it is not smooth. Then I tried VectorForce it is smooth but does not go to the mouse’s location keep in mind both scripts on the velocity and vector are the same except the vector force part.
--Local script
local Tool = script.Parent
local ShootEvent = Tool:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local speed = Vector3.new(75,90,75) --90
local Debounce = true
Tool.Activated:Connect(function()
if Debounce then
Debounce = false
ShootEvent:FireServer(mouse.hit.LookVector * speed)
wait(2)
Debounce = true
end
end)
-------------------------------
-- Server Script
local Debris = game:GetService("Debris")
local Tool = script.Parent
local Handle = Tool.Handle
local ShootEvent = Tool:WaitForChild("RemoteEvent")
ShootEvent.OnServerEvent:Connect(function(player, Velocity)
local newBullet = Instance.new("Part")
newBullet.Size = Vector3.new(.25,.25,1)
newBullet.Color = Color3.fromRGB(255, 210, 9)
newBullet.Material = Enum.Material.Neon
newBullet.Parent = game.Workspace
newBullet.Position = Handle.Position
newBullet.CFrame = Handle.CFrame
newBullet.CanCollide = true
local mass = newBullet:GetMass()
local attach = Instance.new("Attachment")
attach.Parent = newBullet
attach.CFrame = newBullet.CFrame
local VectForce = Instance.new("VectorForce")
VectForce.Parent = newBullet
VectForce.Attachment0 = attach
VectForce.ApplyAtCenterOfMass = true
VectForce.RelativeTo = ("Attachment0")
VectForce.Enabled = true
VectForce.Force = Velocity
print(VectForce.Force)
local TouchConn = newBullet.Touched:Connect(function(hit)
if hit ~= Handle and hit ~= Handle and not Tool.Parent:FindFirstChild(hit.Name) then
if hit.Parent:FindFirstChild("Humanoid") then
wait(.01)
newBullet:Destroy()
Handle.Transparency = 0
end
end
end)
wait(1)
if TouchConn ~= nil and game.Workspace:FindFirstChildOfClass("Part") then
Handle.Transparency = 0
end
wait(4.5)
if TouchConn ~= nil and game.Workspace:FindFirstChildOfClass("Part") then
Handle.Transparency = 0
newBullet:Destroy()
end
end)