概要
代码示例
给玩家添加闪光
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- 添加与玩家 torso 颜色相同的闪光
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)API 参考
属性
Color
Enabled
代码示例
给玩家添加闪光
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- 添加与玩家 torso 颜色相同的闪光
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)启用
local Debris = game:GetService("Debris")
local part = Instance.new("Part")
part.Parent = workspace
local sparkles = Instance.new("Sparkles")
sparkles.Parent = part
function stopSparkling(sparkles)
sparkles.Enabled = false -- 不再生成新粒子
Debris:AddItem(sparkles, 4) -- 在延迟后移除对象(在现有粒子过期后)
end
stopSparkling(part.Sparkles)SparkleColor
代码示例
给玩家添加闪光
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- 添加与玩家 torso 颜色相同的闪光
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)