Ghi chú phát hành
Học
Lớp công cụ
Model

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Phương Pháp
AddPersistentPlayer(playerInstance: Player):()
BreakJoints():()
Đã Lỗi Thời
breakJoints():()
Đã Lỗi Thời
GetModelCFrame():CFrame
Đã Lỗi Thời
GetModelSize():Vector3
Đã Lỗi Thời
GetPrimaryPartCFrame():CFrame
Đã Lỗi Thời
MakeJoints():()
Đã Lỗi Thời
makeJoints():()
Đã Lỗi Thời
move(location: Vector3):()
Đã Lỗi Thời
MoveTo(position: Vector3):()
moveTo(location: Vector3):()
Đã Lỗi Thời
RemovePersistentPlayer(playerInstance: Player):()
ResetOrientationToIdentity():()
Đã Lỗi Thời
ScaleTo(newScaleFactor: number):()
SetIdentityOrientation():()
Đã Lỗi Thời
SetPrimaryPartCFrame(cframe: CFrame):()
Đã Lỗi Thời
TranslateBy(delta: Vector3):()
Thành viên kế thừa
Được kế thừa bởi
Mẫu mã
Khởi Tạo Mô Hình Cơ Bản
local function groupObjects(objectTable)
local model = Instance.new("Model")
for _, object in pairs(objectTable) do
object.Parent = model
end
return model
end
local objects = {
Instance.new("Part"),
Instance.new("Part"),
}
groupObjects(objects)

Tài Liệu Tham Khảo API
Thuộc Tính
LevelOfDetail
Bảo Mật Plugin
Đọc Song Song
Model.LevelOfDetail:Enum.ModelLevelOfDetail

ModelStreamingMode
Đọc Song Song
Model.ModelStreamingMode:Enum.ModelStreamingMode

PrimaryPart
Đọc Song Song
Model.PrimaryPart:BasePart
Mẫu mã
Ném Xúc Xắc
-- Tạo một mô hình xúc xắc với hai nửa và gắn chúng lại với nhau
local diceModel = Instance.new("Model")
diceModel.Name = "ChanceCube"
local diceTop = Instance.new("Part")
diceTop.Size = Vector3.new(4, 2, 4)
diceTop.Position = Vector3.new(0, 1, 0)
diceTop.Color = Color3.new(0, 0, 1)
diceTop.Parent = diceModel
local diceBottom = diceTop:Clone()
diceBottom.Position = Vector3.new(0, -1, 0)
diceBottom.Color = Color3.new(1, 0, 0)
diceBottom.Parent = diceModel
local weld = Instance.new("WeldConstraint")
weld.Part0 = diceTop
weld.Part1 = diceBottom
weld.Parent = diceModel
-- Đưa xúc xắc lên không trung bên trên gốc không gian làm việc (không yêu cầu một phần chính)
diceModel.Parent = workspace
diceModel:PivotTo(CFrame.new(0, 10, 0))
-- Gán phần chính trước khi mô phỏng vật lý
-- Nếu không có dòng này, script sẽ luôn xuất cùng một thứ và bounding box của mô hình sẽ không thay đổi hướng
diceModel.PrimaryPart = diceTop
-- Chờ một chút trước khi lăn xúc xắc (để nó ổn định xuống sàn)
for i = 5, 1, -1 do
print("Đang lăn xúc xắc trong...", i)
task.wait(1)
end
diceTop:ApplyAngularImpulse(Vector3.new(15000, 1000, 5000))
diceTop:ApplyImpulse(Vector3.new(0, 3000, 0))
task.wait(1)
-- Chờ cho việc lăn hoàn tất
while diceTop.AssemblyLinearVelocity.Magnitude > 0.1 or diceTop.AssemblyAngularVelocity.Magnitude > 0.1 do
task.wait()
end
-- Lấy hướng của xúc xắc, bị ảnh hưởng bởi phần chính
local orientation = diceModel:GetBoundingBox()
if orientation.YVector.Y > 0.5 then
print("Đó là cậu bé!")
else
print("Đó là mẹ của nó!")
end

Scale
Không Sao Chép
Không Thể Viết Kịch Bản
Đọc Song Song
Model.Scale:number

WorldPivot
Không Sao Chép
Đọc Song Song
Model.WorldPivot:CFrame
Mẫu mã
Đặt lại Pivot
local function resetPivot(model)
local boundsCFrame = model:GetBoundingBox()
if model.PrimaryPart then
model.PrimaryPart.PivotOffset = model.PrimaryPart.CFrame:ToObjectSpace(boundsCFrame)
else
model.WorldPivot = boundsCFrame
end
end
resetPivot(script.Parent)

Phương Pháp
AddPersistentPlayer
Model:AddPersistentPlayer(playerInstance:Player):()
Tham Số
playerInstance:Player
Giá Trị Mặc Định: "nil"
Lợi Nhuận
()

BreakJoints
Đã Lỗi Thời

breakJoints
Đã Lỗi Thời

GetBoundingBox
Model:GetBoundingBox():Tuple
Lợi Nhuận

GetExtentsSize
Model:GetExtentsSize():Vector3
Lợi Nhuận
Mẫu mã
Lấy kích thước Bounding Box của Mô Hình
local model = Instance.new("Model")
model.Parent = workspace
local RNG = Random.new()
for _ = 1, 5 do
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(RNG:NextNumber(0.05, 5), RNG:NextNumber(0.05, 5), RNG:NextNumber(0.05, 5))
part.Parent = model
end
print(model:GetExtentsSize())

GetModelCFrame
Đã Lỗi Thời

GetModelSize
Đã Lỗi Thời

GetPersistentPlayers
Model:GetPersistentPlayers():{Player}
Lợi Nhuận

GetPrimaryPartCFrame
Đã Lỗi Thời

GetScale
Quyền sử dụng chế độ mô phỏng
Model:GetScale():number
Lợi Nhuận
Mẫu mã
Thay thế một mô hình thay thế bằng cách sử dụng PivotTo và ScaleTo
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Tìm tất cả các mô hình với thẻ mà chúng ta muốn thay thế
local items = CollectionService:GetTagged("Tree")
local newModel = ReplicatedStorage.FancyTreeReplacementModel
for _, item in items do
-- Tạo mục mới và thu nhỏ / định vị nó ở nơi mục cũ
local newItem = newModel:Clone()
newItem:ScaleTo(item:GetScale())
newItem:PivotTo(item:GetPivot())
-- Thêm cùng một thẻ vào mục thay thế
CollectionService:AddTag(newItem, "Tree")
-- Xóa mục cũ và bố trí mục mới
newItem.Parent = item.Parent
item:Destroy()
end

MakeJoints
Đã Lỗi Thời

makeJoints
Đã Lỗi Thời

move
Đã Lỗi Thời

MoveTo
Model:MoveTo(position:Vector3):()
Tham Số
position:Vector3
Lợi Nhuận
()
Mẫu mã
Mô Hình Di Chuyển Đến
local START_POSITION = Vector3.new(-20, 10, 0)
local END_POSITION = Vector3.new(0, 10, 0)
local model = Instance.new("Model")
model.Parent = workspace
local part1 = Instance.new("Part")
part1.Size = Vector3.new(4, 4, 4)
part1.Position = START_POSITION
part1.Anchored = true
part1.BrickColor = BrickColor.new("Màu vàng sáng")
part1.Parent = model
local part2 = Instance.new("Part")
part2.Size = Vector3.new(2, 2, 2)
part2.Position = START_POSITION + Vector3.new(0, 3, 0)
part2.Anchored = true
part2.BrickColor = BrickColor.new("Màu xanh sáng")
part2.Parent = model
model.PrimaryPart = part1
model.Parent = workspace
local obstruction = Instance.new("Part")
obstruction.Name = "Cản"
obstruction.Size = Vector3.new(10, 10, 10)
obstruction.Position = Vector3.new(0, 10, 0)
obstruction.Anchored = true
obstruction.BrickColor = BrickColor.new("Màu xanh lá sáng")
obstruction.Parent = workspace
task.wait(3)
model:MoveTo(END_POSITION)

moveTo
Đã Lỗi Thời

RemovePersistentPlayer
Model:RemovePersistentPlayer(playerInstance:Player):()
Tham Số
playerInstance:Player
Giá Trị Mặc Định: "nil"
Lợi Nhuận
()

ResetOrientationToIdentity
Đã Lỗi Thời

ScaleTo
Model:ScaleTo(newScaleFactor:number):()
Tham Số
newScaleFactor:number
Lợi Nhuận
()

SetIdentityOrientation
Đã Lỗi Thời

SetPrimaryPartCFrame
Đã Lỗi Thời

TranslateBy
Model:TranslateBy(delta:Vector3):()
Tham Số
delta:Vector3
Lợi Nhuận
()
Mẫu mã
Mô hình TranslateBy
local START_POSITION = Vector3.new(-20, 10, 0)
local END_POSITION = Vector3.new(0, 10, 0)
local model = Instance.new("Model")
local part1 = Instance.new("Part")
part1.Size = Vector3.new(4, 4, 4)
part1.CFrame = CFrame.new(START_POSITION) * CFrame.Angles(0, math.rad(45), 0)
part1.Anchored = true
part1.BrickColor = BrickColor.new("Bright yellow")
part1.Parent = model
local part2 = Instance.new("Part")
part2.Size = Vector3.new(2, 2, 2)
part2.CFrame = part1.CFrame * CFrame.new(0, 3, 0)
part2.Anchored = true
part2.BrickColor = BrickColor.new("Bright blue")
part2.Parent = model
model.PrimaryPart = part1
model.Parent = workspace
local obstruction = Instance.new("Part")
obstruction.Name = "Obstruction"
obstruction.Size = Vector3.new(10, 10, 10)
obstruction.Position = Vector3.new(0, 10, 0)
obstruction.Transparency = 0.5
obstruction.Anchored = true
obstruction.BrickColor = BrickColor.new("Bright green")
obstruction.Parent = workspace
task.wait(3)
-- sử dụng TranslateBy để chuyển mô hình vào phần cản
model:TranslateBy(END_POSITION - START_POSITION)

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.