閃光是幾種粒子發射類別之一。像其他類似粒子發射器一樣,火花對象在與父級(例如,一個>或在此父級內的一個>中)或在此父級內的一個>相關時發射粒子。與 ParticleEmitter 類比,閃光缺乏許多不同的自訂屬性和特殊方法,例如 ParticleEmitter.Lifetime 或 ParticleEmitter:Emit() 。在有限時間內創建快速特效有用;如果需要更詳細的工作,則建議使用 ParticleEmitter 來取代。
當 Sparkles.Enabled 被切換關閉時,這個對象發出的粒子將繼續渲染,直到它們的生命週期到期。當閃光物件的 Instance.Parent 設為 nil (和/或 Instance:Destroy() 編輯)時,所有粒子將立即消失。如果這個效果不是想要的,請試著將父對象隱藏在遠處的位置,然後使用 Debris 在幾秒鐘後移除閃光,讓最後一些粒子有機會過期。此對象沒有 ParticleEmitter:Clear() 方法,但可以將 Instance.Parent 設置為 nil 並返回到相同效果的對象。
閃光粒子只從BasePart中心發射到他們的父輩。將閃光對象轉換為 Attachment 而不是允許父母化閃光粒子的起始位置的自訂。
範例程式碼
The code sample below gives any new players sparkles that are colored the same as their torso color.
Give Sparkles
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- Add sparkles that are colored to the player's torso color
local sparkles = Instance.new("Sparkles")
sparkles.Parent = hrp
sparkles.SparkleColor = character:WaitForChild("Body Colors").TorsoColor.Color
sparkles.Enabled = true
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterSpawned)
end
Players.PlayerAdded:Connect(onPlayerAdded)
概要
屬性
決定閃光粒子的顏色。
決定是否發出閃光。
決定閃光粒子的顏色。
屬性
Color
範例程式碼
Give Sparkles
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- Add sparkles that are colored to the player's torso color
local sparkles = Instance.new("Sparkles")
sparkles.Parent = hrp
sparkles.SparkleColor = character:WaitForChild("Body Colors").TorsoColor.Color
sparkles.Enabled = true
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterSpawned)
end
Players.PlayerAdded:Connect(onPlayerAdded)
Enabled
範例程式碼
Give Sparkles
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- Add sparkles that are colored to the player's torso color
local sparkles = Instance.new("Sparkles")
sparkles.Parent = hrp
sparkles.SparkleColor = character:WaitForChild("Body Colors").TorsoColor.Color
sparkles.Enabled = true
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterSpawned)
end
Players.PlayerAdded:Connect(onPlayerAdded)
LocalTransparencyModifier
SparkleColor
範例程式碼
Give Sparkles
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- Add sparkles that are colored to the player's torso color
local sparkles = Instance.new("Sparkles")
sparkles.Parent = hrp
sparkles.SparkleColor = character:WaitForChild("Body Colors").TorsoColor.Color
sparkles.Enabled = true
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterSpawned)
end
Players.PlayerAdded:Connect(onPlayerAdded)