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

Why is the explosion spawning where my character spawned?

wait(3)
Player = script.Parent.Parent.Parent
n = script.Parent
mouse = Player:GetMouse()
run = game:GetService("RunService")
local debounce =  false
function pizza(mouse)
	if debounce == false then
		debounce = true		
			local x = Instance.new("Part")
			x.Shape = "Block"
			x.CanCollide = false
			x.TopSurface = "Smooth"
			x.BottomSurface = "Smooth"
			x.Transparency = 0
			x.Reflectance = 0.3
			x.Parent = Workspace
			x.Rotation = Vector3.new(-89.998, 0.013, -89.972)
			x.Size = Vector3.new(10, 5, 10)
			x.BrickColor = BrickColor.new("Institutional white")
			x.Name = Player.Name
			y = Instance.new("BodyVelocity")
			y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
			y.velocity = Player.Character.Torso.CFrame.lookVector*60
			x.Parent = Workspace
			y.Parent = x
			f = Instance.new("SpecialMesh", x)
			f.MeshType = "FileMesh"
			f.MeshId = "http://www.roblox.com/asset/?id=51226819 "
			f.Scale = Vector3.new(10, 5, 10)
			h = Instance.new("Explosion")
			h.Parent = x
			x.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, -10)
			game.Debris:AddItem(x, 10)
			x.Touched:connect(function(Part) 
    if Part.Parent:FindFirstChild("Humanoid") ~= nil then
		script.Disabled = true
		for i = 1,20 do  
        Part.Parent.Humanoid.Health =  Part.Parent.Humanoid.Health -1
		wait(0.05)
		end
		script.Disabled = false
    end
	wait(0.025)
end)
		end
		wait(60)
		debounce = false
	end


function onSelected(mouse)
	mouse.Button1Down:connect(function() pizza(mouse) end)
end

n.Selected:connect(onSelected)

1 comment

0

Line 33 has you setting the explosion 10 studs below your character... It's doing exactly what you told it to.

1 answer

Explosions don't inherit the position of their parent. You need to define their position and then parent them.

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