Script runs too slow

I have made a gun script, and it works perfectly fine, except for the fact that it runs too slow, so the bullet moves slowly and makes the game seem like it is in slow-motion. Here is a clip. As you can see, the bullet moves slowly. Do you have any idea on how to make it work faster? Any help is appreciated. Thank you!

local Mouse = LocalPlayer:GetMouse()

local RunService = game:GetService'RunService'

local function CalculateLandingPoint(Origin, Velocity, Dip, Orientation) -- Projectile flies from Origin with a Velocity vector
	local StartTime = tick()
	local StartPosition = Origin.Position
	local OriginPos = StartPosition
	local bullet ="Part")
	Orientation = Orientation + 90
	bullet.Shape = Enum.PartType.Cylinder
	bullet.Size =,0.2,0.2)
	bullet.Position = OriginPos
	bullet.Anchored = true
	bullet.CanCollide = false
	bullet.Parent = workspace
	local LastPos
	local CFrames = {}
	while true do
		if tick() - StartTime >= 3 then print("Unable to find object") break end
		local Delta = RunService.RenderStepped:Wait()
		local ray =, Velocity)
		local Hit, HitPosition = workspace:FindPartOnRayWithIgnoreList(ray,{LocalPlayer.Character})
		if Hit then
			if not LastPos then
				LastPos = OriginPos
			Velocity = Velocity -, workspace.Gravity * Delta / Dip,0) -- Divide by 100 so projectile doesn't fall too fast (for testing purposes)
			StartPosition = HitPosition
			local LookAngle = math.deg(math.sin((HitPosition.Y-LastPos.Y)/(HitPosition-LastPos).Magnitude))
			LastPos = HitPosition
			bullet.CFrame = * CFrame.fromEulerAnglesXYZ(0,math.rad(Orientation),math.rad(LookAngle))

	local Root = LocalPlayer.Character.PrimaryPart
	local MouseCFrame = Mouse.Origin
	CalculateLandingPoint(Root.CFrame, MouseCFrame.LookVector, 1000, Root.Orientation.Y)
1 Like

i am not a pro in scripting but try adding wait(0) at first?

Can we see a portion of the script so that we can determine whats up? Maybe just the part that is being delayed. My best guess so far is that you have a wait(n) somewhere in there and its causing yielding, so you should definitely check out this.

Edit: If your tweening the bullet, use the module above and make the wait of the tween a smaller number. If your using a force, up the values

1 Like

You can just increase the speed of the bullet in your script.

As @rottendogDkRsaid, increase the speed of the bullet. If you’re using the script I helped you fix earlier then just multiply the 2nd Velocity Argument by a number like 5 or 10.

	CalculateLandingPoint(Origin, Velocity * 10)
1 Like

I have provided the script. It goes in a tool.

I think what causes the most delay is the CFrames. When I remove them, it works somewhat quicker.

The script you have is as fast as a script can run, every frame. The only think you can really do is increase the speed of the bullet

1 Like