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

Why is the "position" of "explosion" not in the part, but in baseplate?

So I have this script, where if I step on the part, an explosion appears in the part. Here's the code:

local part = game.Workspace.Boom
local db = false


function Boom(hit)
	local human = hit.Parent:FindFirstChild("Humanoid")
	local explosion = Instance.new("Explosion", game.Workspace)
	if not db then
	    if human then
		db = true
		wait(2)
		explosion.Position = part.Position
		wait(2)
		
		db = false
		
		end
	end
end


part.Touched:connect(Boom)

The problem is, the explosion doesn't appear in the brick. It appears in the baseplate instead. Any suggestions?

1 answer

✓ Accepted answer

Because the explosion blows up before you set the Position. Create the explosion before right after you make it, without any waits.

local part = game.Workspace.Boom
local db = false


function Boom(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    if not db then
        if human then
        db = true
        wait(2)
        local explosion = Instance.new("Explosion", game.Workspace)
        explosion.Position = part.Position
        wait(2)

        db = false

        end
    end
end
part.Touched:connect(Boom)

Good Luck!

If I helped, please don't forget to accept my answer.

1 comment

0

Thanks!

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