學習
引擎類別
Trail

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


範例程式碼
創建具有基本尾跡的部件
local TweenService = game:GetService("TweenService")
-- 創建一個父部件
local part = Instance.new("Part")
part.Material = Enum.Material.SmoothPlastic
part.Size = Vector3.new(4, 1, 2)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Parent = workspace
-- 在部件上創建附件
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment0.Position = Vector3.new(-2, 0, 0)
attachment0.Parent = part
local attachment1 = Instance.new("Attachment")
attachment1.Name = "Attachment1"
attachment1.Position = Vector3.new(2, 0, 0)
attachment1.Parent = part
-- 創建一個新的尾跡
local trail = Instance.new("Trail")
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
trail.Parent = part
-- Tween 部件以顯示尾跡
local dir = 15
while true do
dir *= -1
local goal = { Position = part.Position + Vector3.new(0, 0, dir) }
local tweenInfo = TweenInfo.new(3)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(4)
end

API 參考
屬性
Attachment0
平行讀取
功能: Basic
Trail.Attachment0:Attachment

Attachment1
平行讀取
功能: Basic
Trail.Attachment1:Attachment

Brightness
平行讀取
功能: Basic
Trail.Brightness:number

Color
平行讀取
功能: Basic
Trail.Color:ColorSequence
範例程式碼
創建具有顏色漸變的拖尾
local TweenService = game:GetService("TweenService")
-- 創建一個父部件
local part = Instance.new("Part")
part.Material = Enum.Material.SmoothPlastic
part.Size = Vector3.new(4, 1, 2)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Parent = workspace
-- 在部件上創建附件
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment0.Position = Vector3.new(-2, 0, 0)
attachment0.Parent = part
local attachment1 = Instance.new("Attachment")
attachment1.Name = "Attachment1"
attachment1.Position = Vector3.new(2, 0, 0)
attachment1.Parent = part
-- 創建具有顏色漸變的新拖尾
local trail = Instance.new("Trail")
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
local color1 = Color3.fromRGB(255, 0, 0)
local color2 = Color3.fromRGB(0, 0, 255)
trail.Color = ColorSequence.new(color1, color2)
trail.Parent = part
-- 將部件過渡以顯示拖尾
local dir = 15
while true do
dir *= -1
local goal = { Position = part.Position + Vector3.new(0, 0, dir) }
local tweenInfo = TweenInfo.new(3)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(4)
end

Enabled
平行讀取
功能: Basic
Trail.Enabled:boolean

FaceCamera
平行讀取
功能: Basic
Trail.FaceCamera:boolean

Lifetime
平行讀取
功能: Basic
Trail.Lifetime:number

LightEmission
平行讀取
功能: Basic
Trail.LightEmission:number

LightInfluence
平行讀取
功能: Basic
Trail.LightInfluence:number

LocalTransparencyModifier
隱藏
未複製
平行讀取
功能: Basic
Trail.LocalTransparencyModifier:number

MaxLength
平行讀取
功能: Basic
Trail.MaxLength:number

MinLength
平行讀取
功能: Basic
Trail.MinLength:number

Texture
平行讀取
功能: Basic
Trail.Texture:ContentId
範例程式碼
使用爪印紋理創建拖尾
local TweenService = game:GetService("TweenService")
-- 創建一個父部件
local part = Instance.new("Part")
part.Material = Enum.Material.SmoothPlastic
part.Size = Vector3.new(2, 1, 2)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Parent = workspace
-- 在部件上創建附加件
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment0.Position = Vector3.new(-1, 0, 0)
attachment0.Parent = part
local attachment1 = Instance.new("Attachment")
attachment1.Name = "Attachment1"
attachment1.Position = Vector3.new(1, 0, 0)
attachment1.Parent = part
-- 使用顏色漸變創建新的拖尾
local trail = Instance.new("Trail")
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
trail.Texture = "rbxassetid://16178262222"
trail.TextureMode = Enum.TextureMode.Static
trail.TextureLength = 2
trail.Parent = part
-- 將部件過渡以顯示拖尾
local dir = 15
while true do
dir *= -1
local goal = { Position = part.Position + Vector3.new(0, 0, dir) }
local tweenInfo = TweenInfo.new(3)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(4)
end

TextureLength
平行讀取
功能: Basic
Trail.TextureLength:number

TextureMode
平行讀取
功能: Basic
Trail.TextureMode:Enum.TextureMode

Transparency
平行讀取
功能: Basic
Trail.Transparency:NumberSequence

WidthScale
平行讀取
功能: Basic
Trail.WidthScale:NumberSequence

方法
Clear
功能: Basic
Trail:Clear():()
返回
()

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