Ghi chú phát hành
Học
Lớp công cụ
Explosion

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Sự Kiện
Thành viên kế thừa
Mẫu mã
Khởi Tạo Sự Nổ
local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- gây tổn hại cho địa hình
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

Tài Liệu Tham Khảo API
Thuộc Tính
BlastPressure
Đọc Song Song
Các khả năng: AvatarBehavior
Explosion.BlastPressure:number
Mẫu mã
Nổ Tùy Chỉnh
local function customExplosion(position, radius, maxDamage)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 0 -- điều này có thể được đặt cao hơn để vẫn áp dụng tốc độ cho các phần
explosion.DestroyJointRadiusPercent = 0 -- các khớp là an toàn
explosion.BlastRadius = radius
explosion.Position = position
-- thiết lập một bảng để theo dõi các mô hình bị trúng
local modelsHit = {}
-- lắng nghe sự liên lạc
explosion.Hit:Connect(function(part, distance)
local parentModel = part.Parent
if parentModel then
-- kiểm tra xem mô hình này đã bị trúng chưa
if modelsHit[parentModel] then
return
end
-- ghi lại mô hình này là bị trúng
modelsHit[parentModel] = true
-- tìm kiếm một humanoid
local humanoid = parentModel:FindFirstChild("Humanoid")
if humanoid then
local distanceFactor = distance / explosion.BlastRadius -- lấy khoảng cách dưới dạng giá trị giữa 0 và 1
distanceFactor = 1 - distanceFactor -- đảo ngược giá trị, để giá trị thấp == gần == nhiều thiệt hại
humanoid:TakeDamage(maxDamage * distanceFactor) -- TakeDamage để tôn trọng ForceFields
end
end
end)
explosion.Parent = game.Workspace
-- Roblox xóa các vụ nổ sau vài giây, nhưng không phá hủy chúng.
-- Để đảm bảo kết nối .Hit của chúng tôi bị ngắt kết nối, hãy hủy diệt vụ nổ một khi nó bị xóa.
explosion.AncestryChanged:Connect(function()
if not explosion.Parent then
explosion:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0), 12, 50)

BlastRadius
Đọc Song Song
Các khả năng: AvatarBehavior
Explosion.BlastRadius:number
Mẫu mã
Khởi Tạo Sự Nổ
local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- gây tổn hại cho địa hình
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

DestroyJointRadiusPercent
Đọc Song Song
Các khả năng: AvatarBehavior
Explosion.DestroyJointRadiusPercent:number
Mẫu mã
Các vụ nổ không gây chết người
local function onDescendantAdded(instance)
if instance:IsA("Explosion") then
local explosion = instance
explosion.DestroyJointRadiusPercent = 0
local destroyJointRadiusPercent = 1
explosion.Hit:Connect(function(part, distance)
-- kiểm tra xem phần có nằm trong phạm vi để phá vỡ các khớp không
if distance <= destroyJointRadiusPercent * explosion.BlastRadius then
-- đảm bảo rằng phần đó không thuộc về một nhân vật
if not game.Players:GetPlayerFromCharacter(part.Parent) then
part:BreakJoints()
end
end
end)
end
end
workspace.DescendantAdded:Connect(onDescendantAdded)
Nổ Tùy Chỉnh
local function customExplosion(position, radius, maxDamage)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 0 -- điều này có thể được đặt cao hơn để vẫn áp dụng tốc độ cho các phần
explosion.DestroyJointRadiusPercent = 0 -- các khớp là an toàn
explosion.BlastRadius = radius
explosion.Position = position
-- thiết lập một bảng để theo dõi các mô hình bị trúng
local modelsHit = {}
-- lắng nghe sự liên lạc
explosion.Hit:Connect(function(part, distance)
local parentModel = part.Parent
if parentModel then
-- kiểm tra xem mô hình này đã bị trúng chưa
if modelsHit[parentModel] then
return
end
-- ghi lại mô hình này là bị trúng
modelsHit[parentModel] = true
-- tìm kiếm một humanoid
local humanoid = parentModel:FindFirstChild("Humanoid")
if humanoid then
local distanceFactor = distance / explosion.BlastRadius -- lấy khoảng cách dưới dạng giá trị giữa 0 và 1
distanceFactor = 1 - distanceFactor -- đảo ngược giá trị, để giá trị thấp == gần == nhiều thiệt hại
humanoid:TakeDamage(maxDamage * distanceFactor) -- TakeDamage để tôn trọng ForceFields
end
end
end)
explosion.Parent = game.Workspace
-- Roblox xóa các vụ nổ sau vài giây, nhưng không phá hủy chúng.
-- Để đảm bảo kết nối .Hit của chúng tôi bị ngắt kết nối, hãy hủy diệt vụ nổ một khi nó bị xóa.
explosion.AncestryChanged:Connect(function()
if not explosion.Parent then
explosion:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0), 12, 50)

ExplosionType
Đọc Song Song
Các khả năng: AvatarBehavior
Explosion.ExplosionType:Enum.ExplosionType
Mẫu mã
Ngăn Chặn Bùng Nổ Gây Hư Hại Địa Hình
local function onDescendantAdded(instance)
if instance:IsA("Explosion") then
instance.ExplosionType = Enum.ExplosionType.NoCraters
instance:GetPropertyChangedSignal("ExplosionType"):Connect(function()
instance.ExplosionType = Enum.ExplosionType.NoCraters
end)
end
end
workspace.DescendantAdded:Connect(onDescendantAdded)

LocalTransparencyModifier
Ẩn
Không Sao Chép
Đọc Song Song
Các khả năng: AvatarBehavior
Explosion.LocalTransparencyModifier:number

Position
Đọc Song Song
Các khả năng: AvatarBehavior
Explosion.Position:Vector3
Mẫu mã
Khởi Tạo Sự Nổ
local explosion = Instance.new("Explosion")
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters -- gây tổn hại cho địa hình
explosion.Position = Vector3.new(0, 10, 0)
explosion.Parent = workspace

TimeScale
Đọc Song Song
Các khả năng: AvatarBehavior
Explosion.TimeScale:number

Visible
Đọc Song Song
Các khả năng: AvatarBehavior
Explosion.Visible:boolean
Mẫu mã
Hình ảnh Tùy chỉnh Bùng nổ
local function customExplosion(position)
local explosion = Instance.new("Explosion")
explosion.Position = position
explosion.Visible = false
local attachment = Instance.new("Attachment")
attachment.Position = position
attachment.Parent = workspace.Terrain
local particleEmitter = Instance.new("ParticleEmitter")
particleEmitter.Enabled = false
particleEmitter.Parent = attachment
particleEmitter.Speed = NumberRange.new(5, 30)
particleEmitter.SpreadAngle = Vector2.new(-90, 90)
explosion.Parent = workspace
particleEmitter:Emit(20)
task.delay(5, function()
if attachment then
attachment:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0))

Sự Kiện
Hit
Các khả năng: AvatarBehavior
Explosion.Hit(
part:BasePart, distance:number
Tham Số
distance:number
Mẫu mã
Nổ Tùy Chỉnh
local function customExplosion(position, radius, maxDamage)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 0 -- điều này có thể được đặt cao hơn để vẫn áp dụng tốc độ cho các phần
explosion.DestroyJointRadiusPercent = 0 -- các khớp là an toàn
explosion.BlastRadius = radius
explosion.Position = position
-- thiết lập một bảng để theo dõi các mô hình bị trúng
local modelsHit = {}
-- lắng nghe sự liên lạc
explosion.Hit:Connect(function(part, distance)
local parentModel = part.Parent
if parentModel then
-- kiểm tra xem mô hình này đã bị trúng chưa
if modelsHit[parentModel] then
return
end
-- ghi lại mô hình này là bị trúng
modelsHit[parentModel] = true
-- tìm kiếm một humanoid
local humanoid = parentModel:FindFirstChild("Humanoid")
if humanoid then
local distanceFactor = distance / explosion.BlastRadius -- lấy khoảng cách dưới dạng giá trị giữa 0 và 1
distanceFactor = 1 - distanceFactor -- đảo ngược giá trị, để giá trị thấp == gần == nhiều thiệt hại
humanoid:TakeDamage(maxDamage * distanceFactor) -- TakeDamage để tôn trọng ForceFields
end
end
end)
explosion.Parent = game.Workspace
-- Roblox xóa các vụ nổ sau vài giây, nhưng không phá hủy chúng.
-- Để đảm bảo kết nối .Hit của chúng tôi bị ngắt kết nối, hãy hủy diệt vụ nổ một khi nó bị xóa.
explosion.AncestryChanged:Connect(function()
if not explosion.Parent then
explosion:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0), 12, 50)

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.