Is this the right way to use it?
function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.F then local mouse = game.Players.LocalPlayer:GetMouse() local gun = workspace.Turret.Gun2 local gunPos= gun.Position local part = Instance.new("Part",workspace) part.Size = Vector3.new(1,1,2) part.Material = "SmoothPlastic" part.Position = gunPos part.CanCollide = false --Workspace -- Part1 -- Vector3Value --I am using a Vector3 Value named "Vector3Value" (the object type) to not interfere in the current Velocity local Force = 1 local Gravity = 1 --The Current Gravity of the Bullet 0-1 |0|None |.5|medium |1|Full local PreVelocity = game.Workspace.Vector3Value PreVelocity.Value = Vector3.new(part.CFrame.LookVector * Force) part.Velocity = Vector3.new(PreVelocity.Value.X,part.Velocity.Y*Gravity,PreVelocity.Value.Z) part.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 3000 end end) end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
A regular Part in the workspace has a property called: Velocity, if you give it a constant value and get the look vector, you can move it in a certain direction going straight. For instance:
Force = 1 --The force you want it to go Part = game.Workspace.Part1 Part.Velocity = Vector3.new(Part.CFrame.LookVector * Force)
Or you can add a custom Y value, so it has gravity
--Workspace -- Part1 -- Vector3Value --I am using a Vector3 Value named "Vector3Value" (the object type) to not interfere in the current Velocity Force = 1 Gravity = 1 --The Current Gravity of the Bullet 0-1 |0|None |.5|medium |1|Full Part = game.Workspace.Part1 PreVelocity = game.Workspace.Vector3Value --Taking the Vector3 of the Part's LookVector and putting it into "Vector3Value": PreVelocity.Value = Vector3.new(Part.CFrame.LookVector * Force) --Stripping the Y Value and using only the X/Z Values for Custom Gravity --Then placing the current Y value of "Part1" into the Velocity Part.Velocity = Vector3.new(PreVelocity.Value.X,Part.Velocity.Y*Gravity,PreVelocity.Value.Z)