How to make my knife throw stay there for 30 second then destroy

how to make my knife throw stay there for 30 second then destroy if the target is not humanoid and this is my script any bug u can help me fix it , thank you

this is my script:
local knife = script.Knife1:Clone()
local newCFrame = CFrame.Angles(0, math.rad(0), 90)
knife.CFrame = stand.HumanoidRootPart.CFrame * CFrame.new(0,0,0)
knife.Parent = workspace
knife.Velocity = stand.HumanoidRootPart.CFrame.lookVector * 60
knife.CFrame = newCFrame

local ignorelist = {}

local antiGravity = Instance.new("BodyForce")
antiGravity.Force = Vector3.new(0, workspace.Gravity * script.Knife1:GetMass(), 0)
antiGravity.Parent = script.Knife1



knife.Touched:Connect(function(hitpart)
	antiGravity:Destroy()
	if not hitpart:IsDescendantOf(Character) then
		knife:Destroy()
		if hitpart.Parent:FindFirstChild("Humanoid") then
			local enemy = hitpart.Parent
			if (table.find(ignorelist,enemy) == nil) then
				table.insert(ignorelist,enemy)
				enemy.Humanoid:TakeDamage(4)
				enemy.Humanoid:LoadAnimation(hitanim):Play()
				local Blood = script.Blood:Clone()
				Blood.Parent = enemy.UpperTorso
				enemy.Humanoid.WalkSpeed = 5
				Enemy.Backpack.Value.UsingMove.Value = true
				wait(1.25)
				knife:Destroy()
				antiGravity:Destroy()
				Blood:Destroy()
				enemy.Humanoid.WalkSpeed = 16
				Enemy.Backpack.Value.UsingMove.Value = false
			end				
		end
	end
end)

end)

this may work:

local ignorelist = {}

local antiGravity = Instance.new("BodyForce")
antiGravity.Force = Vector3.new(0, workspace.Gravity * script.Knife1:GetMass(), 0)
antiGravity.Parent = script.Knife1



knife.Touched:Connect(function(hitpart)
	antiGravity:Destroy()
	if not hitpart:IsDescendantOf(Character) then
		knife:Destroy()
		if hitpart.Parent:FindFirstChild("Humanoid") then
			local enemy = hitpart.Parent
			if (table.find(ignorelist,enemy) == nil) then
				table.insert(ignorelist,enemy)
				enemy.Humanoid:TakeDamage(4)
				enemy.Humanoid:LoadAnimation(hitanim):Play()
				local Blood = script.Blood:Clone()
				Blood.Parent = enemy.UpperTorso
				enemy.Humanoid.WalkSpeed = 5
				Enemy.Backpack.Value.UsingMove.Value = true
				wait(1.25)
				knife:Destroy()
				antiGravity:Destroy()
				Blood:Destroy()
				enemy.Humanoid.WalkSpeed = 16
				Enemy.Backpack.Value.UsingMove.Value = false
			end				
		end
	end
else
spawn(function()
    wait(30)
    Knife:Destroy()
end)
end)
end)
1 Like

Is my script got bug or error?

It is up to you to test it, as I don’t have all the other scripts from your place.

The script I provided is a slightly modified version of the script you provided.