The problem with throwing dynamite

Script:

local db = false

local direction

local debris = game:GetService("Debris")


script.Parent.Throwing.OnServerEvent:Connect(function(player, mouseOp)
	direction = mouseOp
end)


script.Parent.Activated:Connect(function()
	if not db then 
		db = true
		
		--Play animation
		local humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
		local ThrowAnim = humanoid:LoadAnimation(script.Throw)
		ThrowAnim:Play()
		
		wait(0.5)
		
		-- Throw the TNT
		print("throwing")
		script.Parent.Handle.Transparency = 1
		local tntClone = script.Parent.Handle:Clone()
		
		tntClone.CFrame = CFrame.new(script.Parent.Handle.Position + script.Parent.Handle.CFrame.LookVector * 3, direction)
		
		--BodyVelocity
		print("Throw")
		local bv = Instance.new("BodyVelocity")
		bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		bv.P = 3000
		
		local ori = 0
		
		spawn(function()
			while wait() do
				ori = ori - 0.1
				tntClone.CFrame = tntClone.CFrame + tntClone.CFrame.LookVector * 4
				tntClone.Orientation = Vector3.new(tntClone.Orientation.X + ori, tntClone.Orientation.Y, tntClone.Orientation.Z)
				print("position")
			end
		end)
		
		-- Touch function for the ball
		
		tntClone.Touched:Connect(function(hit)
			print("destroy")
			--tntClone:Destroy()
			-- Effects
		end)
	end
end)

Local Script:

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()

script.Parent.Activated:Connect(function()
	script.Parent.Throwing:FireServer(mouse.Hit.p)
	print(mouse.Hit.p)
end)

So I have a script for throwing dynamite, except that the problem is that when I throw it happens this situation:

This is what it says in output:

Question why I have dynamite disappears and does not get into the check touched? That is, it is sort of thrown, but then disappears, why?

Here, the β€œtntClone” is a clone of the handle, which has been set transparent in the previous line, therefore the dynamite will be invisible when thrown.
I’m not sure why the touched even is not checked, maybe post a video after the tnt is visible.

1 Like

Okay, I did it like this:

script.Parent.Handle.Transparency = 1
		local tntClone = script.Parent.Handle:Clone()
		tntClone.Transparency = 0

But for some reason the dynamite disappears again.

hmm, maybe try disabling the bodyvelocity and also the spawn function first to see whether it’s invisible or just flying away too quickly.

well I disabled this function:

-- Throw the TNT
		print("throwing")
		script.Parent.Handle.Transparency = 1
		local tntClone = script.Parent.Handle:Clone()
		tntClone.Transparency = 0
		
		tntClone.CFrame = CFrame.new(script.Parent.Handle.Position + script.Parent.Handle.CFrame.LookVector * 3, direction)
		
		--BodyVelocity
		--print("Throw")
		--local bv = Instance.new("BodyVelocity")
		--bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		--bv.P = 3000
		
		--local ori = 0
		
		--spawn(function()
		--	while wait() do
		--		ori = ori - 0.1
		--		tntClone.CFrame = tntClone.CFrame + tntClone.CFrame.LookVector * 4
		--		tntClone.Orientation = Vector3.new(tntClone.Orientation.X + ori, tntClone.Orientation.Y, tntClone.Orientation.Z)
		--		print("position")
		--	end
		--end)
		
		-- Touch function for the ball
		
		tntClone.Touched:Connect(function(hit)
			print("destroy")
			--tntClone:Destroy()
			-- Effects
		end)

But as you can see it still disappears

Maybe try parenting the dynamite to workspace? I think cloning things does not preserve the parent