Issue with Part Velocity

I am attempting to make a tool that can launch “Bullets” and accurately hit the target directly where the mouse is positioned.

I have concluded upon using part velocity to launch these bullets to their desired target, however part velocity seems to have a range limit regardless of what the speed is set to.

I used a brief tutorial on how to use part velocity to get me where I am now, however there seems to be no topics regarding my issue.

Here is the velocity code, the bullet is “looking” at the target which is positioned directly at the player’s mouse coordinates, then it is launched in that direction.

clone.CFrame  = CFrame.lookAt(clone.Position, trget.Position)
	
	local Speed = 900
	
	 clone.Velocity =  clone.CFrame.LookVector * Speed 

Regardless of the speed, if the player stands far enough away it is inaccurate and the bullet will not hit the desired target.

Hi! Try to use this:

local clone = bullet:Clone()
clone.Parent = workspace
clone.Anchored = false
clone.CanCollide = false
clone.CFrame = character.HumanoidRootPart.CFrame
clone.CFrame = CFrame.lookAt(clone.Position, trget.Position)

local bv = Instance.new("BodyVelocity", clone)
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Velocity = clone.CFrame.LookVector*900

game.Debris:AddItem(clone, 1) --after 1 sec bullet will destroy

Unfortunately it seems to still be inaccurate, the bullets only hit the target rarely from a close distance

make it so that the gravity of the bullet is nearly like the workspace gravity using an bodyforce so that it doenst fall too earlier
(i guess)

Sorry, I don’t understand what you are proposing I do. Could you elaborate?

Alr, firstly create a RemoveEvent and name it “CreateBullet”, replace it into ReplicatedStorage. Then create LocalScript in StarterGui and paste in it this:

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character ~= nil
local char = plr.Character
local mouse = plr:GetMouse()

mouse.Button1Down:Connect(function()
	game.ReplicatedStorage:FindFirstChild("CreateBullet"):FireServer(mouse.Hit)
end)

Then create server script (Script) in ServerScriptService and paste in it this:

game.ReplicatedStorage:FindFirstChild("CreateBullet").OnServerEvent:Connect(function(plr, cf)
	local character = plr.Character
	local clone = bullet:Clone()
	clone.Parent = workspace
	clone.Anchored = false
	clone.CanCollide = false
	clone.CFrame = character.HumanoidRootPart.CFrame
	clone.CFrame = CFrame.lookAt(clone.Position, cf.Position)

	local bv = Instance.new("BodyVelocity", clone)
	bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	bv.Velocity = clone.CFrame.LookVector*900

	game.Debris:AddItem(clone, 1)
end)

Try this

make an body force inside the bullet and set the bodyforce Y to like 192.6 nearly like the gravity of workspace
it will take kinda long if the workspace gravity is 196.2

Turns out I overlooked this, the reason why it was not working was because it was a bit too fast and all I had to do was slow it down, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.