Issue with knife ability

Hello fellow developers! I started scripting one of the first models I made in blender, I started making it have 4 different skills, the first one was fine but the second one had an issue. The second one pretty much made it rain knives on anyone in a 25 stud radius. I want to make it so it so it randomly spawns like a little to the side or infront like completely random but I’m afraid it will get in the way of the handle being aligned with the blade, how can I fix this?

Here is my code:

script.Parent.KnifeRainEvent.OnServerEvent:Connect(function(plr)
	local char = plr.Character
	local root = char.HumanoidRootPart
	local hum = char.Humanoid
	local ts = game:GetService("TweenService")
	local folder = game.Lighting.KnifeRainFolder
	for i,v in pairs(workspace:GetChildren()) do
		if v:FindFirstChild("Humanoid") and v:FindFirstChild("HumanoidRootPart") then
			if (root.Position - v.HumanoidRootPart.Position).Magnitude <25 and v ~= char then
				local handle2 = folder.KnifeRainHandle:Clone()
				local blade2 = folder.KnifeRainBlade:Clone() 
				for i = 1,20 do
				local handle = handle2:Clone()
				local blade = blade2:Clone()
				blade.Parent = workspace
				handle.Parent = workspace
				blade.CFrame = v.HumanoidRootPart.CFrame * CFrame.new(0,15,0)
				handle.CFrame = blade.CFrame * CFrame.new(0,1.44,0)
				blade.Orientation = blade.Orientation + Vector3.new(0,0,180)
				handle.Orientation = handle.Orientation + Vector3.new(0,180,180)
				local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0)
				local properties = {CFrame = blade.CFrame * CFrame.new(0,15,0)}
				ts:Create(blade,info,properties):Play()
				local properties2 = {CFrame = handle.CFrame * CFrame.new(0,15,0)}
				ts:Create(handle,info,properties2):Play() do
				wait(0.1)
					end
				end
			end
		end
	end
end)

Thank you for any help!

1 Like