Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is this Explosion Position Error?

So I created an exploding part that regens explode on contact.

When there is one, there is no problems at all, the script works perfectly from what I can tell, no errors. Proof: https://gyazo.com/3e57523d278005c8084db01dd2700ee5

However, when there are two of them, the new exploding part I copied and pasted messes up and doesn't position the explosion nor the rest of the script. The original exploding part proceeds to explode both of them. Proof: https://gyazo.com/f002e2d7a3e35f736b597dfcced4ffab

The script is located in game.Workspace.ExplodingPart

Any of ways to refine this script would be highly appreciated as well. I'm new to this so sorry if it seems disorganized.

-- Declarations
script.Parent.Anchored = true;
script.Parent.CanCollide = true;
ExplodingPart = game.Workspace.ExplodingPart;
local cooldown = 5;
local ExplosionEnable = true;

-- Explode Function
function Explode(part)
	local human = part.Parent:FindFirstChild("Humanoid");
	if ExplosionEnable ~= false and human ~= false then
		Instance.new("Explosion", script.Parent);
		ExplodingPart:WaitForChild("Explosion");
		ExplodingPart.Explosion.Position = script.Parent.Position;
		script.Parent.Transparency = 1;
		ExplosionEnable = false;
		script.Parent.CanCollide = false;
		wait(5);
		script.Parent.CanCollide = true;
		script.Parent.Transparency = 0;
		ExplosionEnable = true;
	end
end

-- Calling out the function "Explode"
script.Parent.Touched:connect(Explode)

1 answer

✓ Accepted answer

Here I fixed it for you... Also make sure this script is under both of the parts and both of the parts are named ExplodingPart

Here is the code I just fixed a few things you can check them out I added a Variable for explosion and all that... To make it a bit simpler...

script.Parent.Anchored = true;
script.Parent.CanCollide = true;
ExplodingPart = game.Workspace.ExplodingPart;
local cooldown = 5;
local ExplosionEnable = true;

function Explode(part)
    local human = part.Parent:FindFirstChild("Humanoid");
    if ExplosionEnable ~= false and human ~= false then
        local explosion = Instance.new("Explosion", script.Parent);
        explosion.Position = script.Parent.Position;
        script.Parent.Transparency = 1;
        ExplosionEnable = false;
        script.Parent.CanCollide = false;
        wait(5);
        script.Parent.CanCollide = true;
        script.Parent.Transparency = 0;
        ExplosionEnable = true;
    end
end
 
script.Parent.Touched:connect(Explode)

This discussion is preserved as it was. New answers, comments, and votes are closed.