เรียนรู้
Engine Class
TweenService
ไม่สามารถสร้าง
บริการ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
วิธีการ
Create(instance: Instance,tweenInfo: TweenInfo,propertyTable: Dictionary):Tween
GetValue(alpha: number,easingStyle: Enum.EasingStyle,easingDirection: Enum.EasingDirection):number
SmoothDamp(current: Variant,target: Variant,velocity: Variant,smoothTime: number,maxSpeed: number?,dt: number?):Tuple
สมาชิกที่ได้รับทอด
ตัวอย่างโค้ด
การสร้าง Tween
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Color = Color3.new(1, 0, 0)
part.Anchored = true
part.Parent = game.Workspace
local goal = {}
goal.Position = Vector3.new(10, 10, 0)
goal.Color = Color3.new(0, 1, 0)
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
การลูปทวิน
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = workspace
local tweenInfo = TweenInfo.new(
2, -- เวลา
Enum.EasingStyle.Linear, -- รูปแบบการทำให้เรียบ
Enum.EasingDirection.Out, -- ทิศทางการทำให้เรียบ
-1, -- จำนวนการทำซ้ำ (เมื่อต่ำกว่า 0 ทวินจะลูปต่อเนื่อง)
true, -- กลับหลัง (ทวินจะกลับหลังเมื่อถึงจุดหมาย)
0 -- เวลาหน่วง
)
local tween = TweenService:Create(part, tweenInfo, { Position = Vector3.new(0, 30, 0) })
tween:Play()
task.wait(10)
tween:Cancel() -- ยกเลิกการอนิเมชั่นหลังจาก 10 วินาที
การหยุดทเวล
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.BrickColor = BrickColor.new("Bright green")
part.Parent = workspace
local goal = {}
goal.Position = Vector3.new(50, 10, 0)
local tweenInfo = TweenInfo.new(10, Enum.EasingStyle.Linear)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(3)
part.BrickColor = BrickColor.new("Bright red")
tween:Pause()
task.wait(2)
part.BrickColor = BrickColor.new("Bright green")
tween:Play()

เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
Create
ความสามารถ: Basic
TweenService:Create(
instance:Instance, tweenInfo:TweenInfo, propertyTable:Dictionary
พารามิเตอร์
instance:Instance
tweenInfo:TweenInfo
propertyTable:Dictionary
ส่งค่ากลับ
ตัวอย่างโค้ด
การสร้าง Tween
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Color = Color3.new(1, 0, 0)
part.Anchored = true
part.Parent = game.Workspace
local goal = {}
goal.Position = Vector3.new(10, 10, 0)
goal.Color = Color3.new(0, 1, 0)
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
การลูปทวิน
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = workspace
local tweenInfo = TweenInfo.new(
2, -- เวลา
Enum.EasingStyle.Linear, -- รูปแบบการทำให้เรียบ
Enum.EasingDirection.Out, -- ทิศทางการทำให้เรียบ
-1, -- จำนวนการทำซ้ำ (เมื่อต่ำกว่า 0 ทวินจะลูปต่อเนื่อง)
true, -- กลับหลัง (ทวินจะกลับหลังเมื่อถึงจุดหมาย)
0 -- เวลาหน่วง
)
local tween = TweenService:Create(part, tweenInfo, { Position = Vector3.new(0, 30, 0) })
tween:Play()
task.wait(10)
tween:Cancel() -- ยกเลิกการอนิเมชั่นหลังจาก 10 วินาที

GetValue
ความสามารถ: Basic
TweenService:GetValue(
alpha:number, easingStyle:Enum.EasingStyle, easingDirection:Enum.EasingDirection
พารามิเตอร์
alpha:number
easingStyle:Enum.EasingStyle
easingDirection:Enum.EasingDirection
ส่งค่ากลับ

SmoothDamp
เขียนพร้อมๆ กัน
ความสามารถ: Basic
การเข้าถึงการจำลองสถานการณ์
TweenService:SmoothDamp(
current:Variant, target:Variant, velocity:Variant, smoothTime:number, maxSpeed:number?, dt:number?
พารามิเตอร์
current:Variant
target:Variant
velocity:Variant
smoothTime:number
maxSpeed:number?
dt:number?
ส่งค่ากลับ

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ