I have two scripts, one that creates and adds the script to the part, and one that explodes the part on touched. Why does the part explode instantly until being removed?
Here is the first:
function createmine()
local mine = Instance.new("Part")
mine.Parent = workspace
mine.Position = game.Workspace:FindFirstChild("master").Position
mine.Name = "mine"
mine.Size = game.Workspace:FindFirstChild("master").Size
end
function expscript()
local mine = game.Workspace:FindFirstChild("mine")
local script = game.ReplicatedStorage:FindFirstChild("explosion")
script:Clone().Parent = mine
end
while true do
wait(2)
if game.Workspace:FindFirstChild("mine") == nil then
createmine()
expscript()
end
wait(2)
end
And here is the one being added:
function OnTouched()
local expl = Instance.new("Explosion")
expl.Position = script.Parent.Position
expl.Parent = script.Parent
wait(1)
script.Parent:Remove()
end
script.Parent.Touched:connect(OnTouched)

1 comment
Ah, thanks!