I made a few edits and I fixed it myself

I am making a c4 explosive. When I place the c4 down and explode it, it does not let me place down any more c4. it gives me no errors.


local tool = script.Parent
local mo
local c4s
local c4ob = game.ServerStorage.C4	
local c4tab = {}



function c4(m)
m.Button1Down:connect(detonate)
m.Button2Down:connect(place)
while true do
mo = m.Hit
wait(0.01)
end
end
--------------------------------
function detonate()
	tool.Handle.Detonation:Play()	
	wait(0.1)
	for i=1,#c4tab do	
	if tool.C4 ~= nil then
		local gui = tool.C4.SurfaceGui.TextLabel.Text
		local det = Instance.new("Explosion",game.Workspace)
		print("detonate")
		c4tab[i].Explosion:Play()
		det.Position = c4tab[i].Position
		det.BlastRadius = 30
		det.BlastPressure = 500000
		det.DestroyJointRadiusPercent = 50
		c4tab[i]:Remove()
	else
		break
	end
	end
	end
-----------------------------------------
function place()
	if #c4tab <5 then
	if  (script.Parent.Parent.Torso.Position - mo.p).magnitude < 25 then
		local c4c = c4ob:Clone()
		c4c.CFrame = CFrame.new(mo.p)
		c4c.Parent = script.Parent
		c4c.u1.CFrame = CFrame.new(mo.p)
		c4c.u2.CFrame =  CFrame.new(mo.p)
		print("placed")
		table.insert(c4tab,c4c)
		c4s = c4c
	end
	end
	end
-----------------------------------------

script.Parent.Equipped:connect(c4)

1 comment

0

Can you put the error please ?