local p=math.pi*4.5 local n=game.Players.LocalPlayer local T=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")game.ReplicatedStorage.Interactions.Client.BeginKnifeThrow.OnClientEvent:connect(function(n,y,x)local V=false local b=nil local F=game.ReplicatedStorage.Interactions.Client.EndKnifeThrow.OnClientEvent:connect(function(p,T)if p==n then V=true b=T end end)local B=nil while not V do local V=wait()local b=(y*-p)*V local F={CFrame=(n.CFrame+x*V)*CFrame.fromEulerAnglesXYZ(b.X,b.Y,b.Z)}B=T:Create(n,TweenInfo.new(V,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),F)B:Play()end F:disconnect()if B~=nil then B:Cancel()end if n.Parent~=nil and b~=nil then n.CFrame=b end end)

local ROTATION_SPEED = math.pi * 4.5

local plr = game.Players.LocalPlayer
local tweenService = game:GetService("TweenService")

game.ReplicatedStorage.Interactions.Client.BeginKnifeThrow.OnClientEvent:connect(function(knife, rotateAxis, velocity)
	
	-- Connect end knife throw
	local stopLoop = false
	local finalCFrame = nil
	local endEvent = game.ReplicatedStorage.Interactions.Client.EndKnifeThrow.OnClientEvent:connect(function(otherKnife, cframe)
		if otherKnife == knife then
			stopLoop = true
			finalCFrame = cframe
		end
	end)
	
	-- Make knife move smoothly
	local currentTween = nil
	while not stopLoop do
	
		-- Wait
		local waitTime = wait()
		
		-- Tween
		local rotateAmt = rotateAxis * (-ROTATION_SPEED) * waitTime
		local goal = {
			CFrame = (knife.CFrame + (velocity * waitTime)) * CFrame.fromEulerAnglesXYZ(rotateAmt.X, rotateAmt.Y, rotateAmt.Z)
		}
		currentTween = tweenService:Create(knife, TweenInfo.new(waitTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), goal)
		currentTween:Play()
		
	end
	
	-- Disconnect event
	endEvent:disconnect()
	
	-- End tween
	if currentTween ~= nil then
		currentTween:Cancel()
	end
	
	-- Set final CFrame
	if knife.Parent ~= nil and finalCFrame ~= nil then
		knife.CFrame = finalCFrame
	end
	
end)
