Projectile freezes midair sometimes

so I have this projectile loop here that works just fine, but

repeat wait(0.01)
			if stopit == true then break end
			game.TweenService:Create(knife,TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{Position = knife.Position + traveldirection.LookVector * ProjectileSpeedPower}):Play()
		Rayc = workspace:Raycast(knife.Position, traveldirection.LookVector * raycast_distance)
		
		traveltime = traveltime + 0.01
		
		if Rayc == nil then
				-- // lol
				game.TweenService:Create(knife,TweenInfo.new(0.1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{Position = knife.Position + traveldirection.LookVector * ProjectileSpeedPower}):Play()
		else
			local dist = (Rayc.Position - knife.Position).Magnitude
			if dist <= max_distance_between_raycast_and_projectile then
					if Rayc.Instance:IsDescendantOf(workspace.Entities) == true then
						local hum = Rayc.Instance.Parent:FindFirstChild("Humanoid")
						if hum ~= nil then
							knife:Destroy()
							
							BasicFuncModule.CreateStun(1.4,"Knife",hum.Parent:FindFirstChild("Stuns"))
							local DamageData = {
								BlockBreak = false,
								Blockable = true,
								Damage = 5,
								Counterable = true,
								DamageIndicatorEnabled = true,
							}
							DamageModule.Damage(Player.Character,hum.Parent,DamageData)
							
							
							stopit = true
						end
						return end
					if Rayc.Instance:IsDescendantOf(workspace.NewMap) == true then
				stopit = true
					knife.Wall:Play()
					knife.Anchored = false
					game.TweenService:Create(knife,TweenInfo.new(0.05,Enum.EasingStyle.Cubic,Enum.EasingDirection.In,0,false,0),{Position = Rayc.Position}):Play()
					
					local weld = Instance.new("WeldConstraint",Rayc.Instance)
				weld.Part0 = Rayc.Instance
				weld.Part1 = knife
					game.Debris:AddItem(weld,10)
					task.spawn(function()
						task.wait(0.05)
						imageonwalls.MakeImage("rbxassetid://29268434",1.4,Rayc.Instance, knife.Position)
						end)
							task.wait(10)
							game.Debris:AddItem(knife,0.6)
				weld:Destroy()
				knife.Anchored = false
				knife.CanCollide = true
game.TweenService:Create(knife,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{Transparency = 1}):Play()
				break
					end
				end
		end
		
		until traveltime >= Travel_Duration
		knife:Destroy()

I have no idea what’s wrong. Sometimes, the knife just freezes midair.

you should check out fastcast.

i think they want to use their own

fastcast is not an entire replacement to the code they have, it is a library thats better suited to firing projectiles than raycast.

I could, but I rather use this method for now. still have no clue with some knives just stop moving. Will look into fastcast though.

Yes, but it’s sometimes more satisfying without libraries and just using your own code. I’ve used Fastcast and I wasn’t satisfied.

1 Like

PS. I converted my projectiles to CFrame, and they’re better now. Gonna give you the solution.

Yes CFrame is more reliable in most cases.

1 Like