我正在尝试创建一个迷宫赛跑者游戏。在开门和关门时,我使用ROBLOX的内置补间服务编写了脚本。我运行并得到“函数Create不是“ UnionOperation”的成员”,我从未听说过此错误,也找不到解决方案。我试图在工会方面做到这一点。我不知道该怎么做。我需要补间才能正常工作(在部分之间留出一些空格)。
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()
答案 0 :(得分:0)
Replace TweenService.Create
with TweenService:Create
TweenService:Create(Door1, TweenInformationIn, Door1Open)
is equivalent to
TweenService.Create(TweenService, Door1, TweenInformationIn, Door1Open)
whereas you called
TweenService.Create(Door1, TweenInformationIn, Door1Open)
So inside TweenService.Create
things went south because Door1
was where TweenService
should have been.
There is actually a code sample in the Robolox manual that shows how to use 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