Sparkles

顯示已棄用項目

*此內容很快就會推出您所選的語言版本。

Sparkles is one of several particle-emitting classes. Like other particle emitters of its kind, Sparkles objects emit particles when parented to a BasePart (such as a Part) or an Attachment within such a BasePart. Compared to the ParticleEmitter class, Sparkles lacks many different customization properties and special methods, such as ParticleEmitter.Lifetime or ParticleEmitter:Emit(). It is useful to create a quick special effect in a pinch; for more detailed work it is preferable to use a ParticleEmitter instead.

When Sparkles.Enabled is toggled off, particles emit by this object will continue to render until their lifetime expires. When a Sparkles object's Instance.Parent is set to nil (and/or Instance:Destroy()ed), all particles will instantly disappear. If this effect is not desired, try hiding the parent object at a far away position, then removing the Sparkles after a few seconds using Debris to give the last particles a chance to expire. This object does not have a ParticleEmitter:Clear() method, but it is possible to set the Instance.Parent to nil and back to the exact same object for the same effect.

Sparkles particles are only emitted from the center of BasePart to which they are parented. Parenting a Sparkles object to an Attachment instead allows customization of the particles' start position.

範例程式碼

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

隱藏
未複製
平行讀取

The Color property determines the color of all the particles emit by a Sparkles object (both existing and future particles). It behaves similarly to ParticleEmitter.Color, except that it is only one color and not a ColorSequence. Sparkles have a natural color sequence applied which is most apparent when this property is set to white; sparkles very faintly animate between a subtle green and red.

It should be noted that sparkles have a partial ParticleEmitter.LightEmission effect, so dark colors tend to render more transparent and white colors look very bright.

範例程式碼

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

平行讀取

The Enabled property, much like ParticleEmitter.Enabled, determines whether sparkle particles are emit. Any particles already emit will continue to render until their lifetime expires. This property is useful for keeping pre-made sparkle effects off until they are needed later. Since sparkle particles are destroyed when the Sparkle object's Instance.Parent is set to nil, this property is useful in allowing existing particles the opportunity to expire before destroying the Fire object altogether. See the function below.


local Debris = game:GetService("Debris")
local part = script.Parent
function stopSparkling(sparkles)
sparkles.Enabled = false -- No more new particles
Debris:AddItem(sparkles, 4) -- Remove the object after a delay (after existing particles have expired)
end
stopSparkling(part.Sparkles)

範例程式碼

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

平行讀取

This property functions identically to Sparkles.Color.

The SparkleColor property determines the color of all the particles emit by a Sparkles object (both existing and future particles). It behaves similarly to ParticleEmitter.Color, except that it is only one color and not a ColorSequence. Sparkles have a natural color sequence applied which is most apparent when this property is set to white; sparkles very faintly animate between a subtle green and red.

It should be noted that sparkles have a partial ParticleEmitter.LightEmission effect, so dark colors tend to render more transparent and white colors look very bright.

範例程式碼

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)

TimeScale

平行讀取

方法

活動