概要
範例程式碼
給予星星效果
local Players = game:GetService("Players")
local function onCharacterSpawned(character)
local hrp = character:WaitForChild("HumanoidRootPart")
-- 添加與玩家的軀幹顏色相同的星星效果
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")
-- 添加與玩家的軀幹顏色相同的星星效果
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")
-- 添加與玩家的軀幹顏色相同的星星效果
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)