概要
属性
代码示例
点燃火把
local Workspace = game:GetService("Workspace")
for _, descendant in Workspace:GetDescendants() do
if descendant.Name == "Torch" and descendant:IsA("BasePart") then
local fire = Instance.new("Fire")
fire.Heat = 10
fire.SecondaryColor = Color3.new(1, 1, 1)
fire.Size = math.max(descendant.Size.X, descendant.Size.Z) -- 选择两个维度中较大的一个
fire.Parent = descendant
end
end切换火焰效果
local part = script.Parent
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = part
local fire = Instance.new("Fire")
fire.Parent = part
local light = Instance.new("PointLight")
light.Parent = part
local function onClick()
fire.Enabled = not fire.Enabled
light.Enabled = fire.Enabled
end
clickDetector.MouseClick:Connect(onClick)API 参考
属性
Enabled
代码示例
启用
local Debris = game:GetService("Debris")
local function douseFlames(fire)
fire.Enabled = false -- 不再生成新粒子
Debris:AddItem(fire, 2) -- 在现有粒子过期后移除对象
end
local part = Instance.new("Part")
part.Anchored = true
part.Parent = workspace
local fire = Instance.new("Fire")
fire.Parent = part
douseFlames(part.Fire)size