概要
範例程式碼
碎片 添加項目
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)
endAPI 參考
屬性
MaxItems
方法
AddItem
返回
()
範例程式碼
碎片 添加項目
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)
endaddItem