"The function Create is not a member of "UnionOperation" 尝试使用 TweenService()
"The function Create is not a member of "UnionOperation" when trying to use the TweenService()
我正在尝试制作迷宫跑酷游戏。在打开和关闭门时,我使用 ROBLOX 的内置补间服务编写了脚本。我 运行 并得到 "The function Create is not a member of "UnionOperation"" 我从未听说过此错误,也找不到解决方案。我正在尝试在 Union 部分执行此操作。我不知道该怎么做。我需要补间按预期工作(补间部分有几个空格)。
TweenService = game:GetService("TweenService")
Door = script.Parent.Door2
Door1 = Door:WaitForChild("Door1")
Door2 = Door:WaitForChild("Door2")
local TweenInformationIn = TweenInfo.new(
6,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
local Door1Open = {CFrame = CFrame.new(1226.993, 131.187, -769.185)}
local Door2Open = {CFrame = CFrame.new(1226.993, 131.187, -814.271)}
local Door1Close = {CFrame = CFrame.new(1226.993, 131.187, -749.831)}
local Door2Close = {CFrame = CFrame.new(1226.993, 131.187, -834.331)}
local Tween1Open = TweenService.Create(Door1, TweenInformationIn, Door1Open)
local Tween2Open = TweenService.Create(Door2, TweenInformationIn,Door2Open)
local TweenClose = TweenService.Create(Door1, TweenInformationIn, Door1Close)
local Tween2Close = TweenService.Create(Door2,TweenInformationIn,Door2Close)
Tween1Open:Play()
Tween2Open:Play()
将TweenService.Create
替换为TweenService:Create
TweenService:Create(Door1, TweenInformationIn, Door1Open)
相当于
TweenService.Create(TweenService, Door1, TweenInformationIn, Door1Open)
而你打电话给
TweenService.Create(Door1, TweenInformationIn, Door1Open)
所以在 TweenService.Create
里面事情变得很糟糕,因为 Door1
是 TweenService
应该在的地方。
在 Robolox 手册中实际上有一个代码示例展示了如何使用 TweenService。
https://developer.roblox.com/api-reference/function/TweenService/Create
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = game.Workspace
local tweenInfo = TweenInfo.new(
2, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(0, 30, 0)})
tween:Play()
wait(10)
tween:Cancel() -- cancel the animation after 10 seconds
我正在尝试制作迷宫跑酷游戏。在打开和关闭门时,我使用 ROBLOX 的内置补间服务编写了脚本。我 运行 并得到 "The function Create is not a member of "UnionOperation"" 我从未听说过此错误,也找不到解决方案。我正在尝试在 Union 部分执行此操作。我不知道该怎么做。我需要补间按预期工作(补间部分有几个空格)。
TweenService = game:GetService("TweenService")
Door = script.Parent.Door2
Door1 = Door:WaitForChild("Door1")
Door2 = Door:WaitForChild("Door2")
local TweenInformationIn = TweenInfo.new(
6,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
local Door1Open = {CFrame = CFrame.new(1226.993, 131.187, -769.185)}
local Door2Open = {CFrame = CFrame.new(1226.993, 131.187, -814.271)}
local Door1Close = {CFrame = CFrame.new(1226.993, 131.187, -749.831)}
local Door2Close = {CFrame = CFrame.new(1226.993, 131.187, -834.331)}
local Tween1Open = TweenService.Create(Door1, TweenInformationIn, Door1Open)
local Tween2Open = TweenService.Create(Door2, TweenInformationIn,Door2Open)
local TweenClose = TweenService.Create(Door1, TweenInformationIn, Door1Close)
local Tween2Close = TweenService.Create(Door2,TweenInformationIn,Door2Close)
Tween1Open:Play()
Tween2Open:Play()
将TweenService.Create
替换为TweenService:Create
TweenService:Create(Door1, TweenInformationIn, Door1Open)
相当于
TweenService.Create(TweenService, Door1, TweenInformationIn, Door1Open)
而你打电话给
TweenService.Create(Door1, TweenInformationIn, Door1Open)
所以在 TweenService.Create
里面事情变得很糟糕,因为 Door1
是 TweenService
应该在的地方。
在 Robolox 手册中实际上有一个代码示例展示了如何使用 TweenService。
https://developer.roblox.com/api-reference/function/TweenService/Create
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = game.Workspace
local tweenInfo = TweenInfo.new(
2, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(0, 30, 0)})
tween:Play()
wait(10)
tween:Cancel() -- cancel the animation after 10 seconds