“尝试使用TweenService()时,函数Create不是”UnionOperation“的成员

问题描述 投票:0回答:1

我正在尝试创建一个Maze Runner游戏。在打开和关闭门时,我使用ROBLOX内置的补间服务编写脚本。我跑,我得到“功能创建不是”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()
lua roblox
1个回答
0
投票

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
© www.soinside.com 2019 - 2024. All rights reserved.