學習
引擎類別
Debris
無法建立
服務

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要
屬性
MaxItems:number
已棄用
方法
AddItem(item: Instance,lifetime: number):()
addItem(item: Instance,lifetime: number):()
已棄用
繼承成員
範例程式碼
碎片 添加項目
local Debris = game:GetService("Debris")
local ball = Instance.new("\
Part")
ball.Anchored = false
ball.Shape = Enum.PartType.Ball
ball.TopSurface\
= Enum.SurfaceType.Smooth
ball.BottomSurface = Enum.SurfaceType.Smooth
ball.Size\
= Vector3.new(1, 1, 1)
local RNG = Random.new()
local MAX_VELOCITY = 10
\
while true do
\tlocal newBall = ball:Clone()
\tnewBall.BrickColor = BrickColor.random()
\tnewBall.CFrame = CFrame.new(0, 30, 0)
\tnewBall.Velocity =
\t\tVector3.new(RNG:NextNumber(-MAX_VELOCITY,\
MAX_VELOCITY), 0, RNG:NextNumber(-MAX_VELOCITY, MAX_VELOCITY))
\tnewBall.Parent\
= game.Workspace
\tDebris:AddItem(newBall, 2)
\ttask.wait(0.1)
end

API 參考
屬性
MaxItems
已棄用

方法
AddItem
功能: Basic
Debris:AddItem(
item:Instance, lifetime:number
):()
參數
lifetime:number
預設值:10
返回
()
範例程式碼
碎片 添加項目
local Debris = game:GetService("Debris")
local ball = Instance.new("\
Part")
ball.Anchored = false
ball.Shape = Enum.PartType.Ball
ball.TopSurface\
= Enum.SurfaceType.Smooth
ball.BottomSurface = Enum.SurfaceType.Smooth
ball.Size\
= Vector3.new(1, 1, 1)
local RNG = Random.new()
local MAX_VELOCITY = 10
\
while true do
\tlocal newBall = ball:Clone()
\tnewBall.BrickColor = BrickColor.random()
\tnewBall.CFrame = CFrame.new(0, 30, 0)
\tnewBall.Velocity =
\t\tVector3.new(RNG:NextNumber(-MAX_VELOCITY,\
MAX_VELOCITY), 0, RNG:NextNumber(-MAX_VELOCITY, MAX_VELOCITY))
\tnewBall.Parent\
= game.Workspace
\tDebris:AddItem(newBall, 2)
\ttask.wait(0.1)
end

addItem
已棄用

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。