【问题标题】:"The function Create is not a member of "UnionOperation" when trying to use the TweenService()“尝试使用 TweenService() 时,函数 Create 不是“UnionOperation”的成员
【发布时间】:2019-09-07 01:51:17
【问题描述】:

我正在尝试创建 Maze Runner 游戏。当让门打开和关闭时,我使用 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()

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    TweenService.Create 替换为TweenService:Create

    TweenService:Create(Door1, TweenInformationIn, Door1Open)
    

    等价于

    TweenService.Create(TweenService, Door1, TweenInformationIn, Door1Open)
    

    当你打电话时

    TweenService.Create(Door1, TweenInformationIn, Door1Open)
    

    所以在TweenService.Create 内部,事情向南走,因为Door1TweenService 应该在的地方。

    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
    

    【讨论】:

      猜你喜欢
      • 2017-04-12
      • 2018-04-12
      • 2018-07-07
      • 1970-01-01
      • 1970-01-01
      • 2016-09-18
      • 2020-12-16
      • 2021-04-03
      • 2020-08-05
      相关资源
      最近更新 更多