使用TweenService时出现"尝试调用TweenInfo值"

我正在为我的游戏制作一个情节选择系统。我希望在点击播放按钮后,情节选择系统GUI可以在屏幕上缓慢移动。但是,我的脚本一遍又一遍地给出"尝试调用TweenInfo值"的错误。这是完整的代码:

local TweenService = game:GetService("TweenService")

local player = game.Players.LocalPlayer
local Camera = game.Workspace.Camera

local PlotSelect = script.Parent:WaitForChild("PlotSelect")

local Frame = PlotSelect:WaitForChild("Frame")
local Left = Frame:WaitForChild("Left")
local Right = Frame:WaitForChild("Right")

local SelectedPlot = Frame:WaitForChild("SelectedPlot")

local Menu = script.Parent:WaitForChild("MainMenuGui")
local Menubg = Menu:WaitForChild("MainMenuBackground")
local Playbutton = Menubg:WaitForChild("PlayButton")

continuescript = false

local Plots = game.Workspace.Plots

Camera.CameraType = Enum.CameraType.Scriptable

local function findUnoccupiedPlots()
    local availablePlots = {}
    for i, plot in pairs(Plots:GetChildren()) do
        if plot.Occupant.Value == nil then
            table.insert(availablePlots,plot)
        end
    end
    return availablePlots
end

local TI = TweenInfo.new(
    0.5,
    Enum.EasingStyle.Quint,
    Enum.EasingDirection.InOut,
    0,
    false,
    0
)

local tweenInfo1 = TweenInfo.new(
    1,
    Enum.EasingStyle.Back,
    Enum.EasingDirection.InOut,
    0,
    false,
    0
)

local tween1 = TweenService:Create(Frame, tweenInfo1 {Position = UDim2.new(0.5, 0, 0.8, 0)})

Playbutton.MouseButton1Click:Connect(function()
    wait(3)
    continuescript = true
end)

repeat
    wait()
until continuescript == true

tween1:Play()


local function camTween(plot)
    local cf = CFrame.new(plot.Position+Vector3.new(0,120,0),plot.Position)
    local tween = TweenService:Create(game.Workspace.Camera,TweenInfo,{CFrame = cf})
    tween:Play()
end

local plotsTable = findUnoccupiedPlots()

local index = 1

SelectedPlot.Value = plotsTable[1]
camTween(SelectedPlot.Value)

Left.MouseButton1Click:Connect(function()
    if Plots:FindFirstChild("Plot"..index-1) then
        index -= 1
    else
        index = 12
    end

    SelectedPlot.Value = plotsTable[index]
    camTween(plotsTable[index])

end)

Right.MouseButton1Click:Connect(function()
    if Plots:FindFirstChild("Plot"..index+1) then
        index += 1
    else
        index = 1
    end

    SelectedPlot.Value = plotsTable[index]
    camTween(plotsTable[index])

end)

我尝试使用TweenPosition代码,但它也不起作用。请帮助我。

点赞
用户2858170
用户2858170
本行代码缺少一个逗号,需要在 `tweenInfo1` 后添加一个逗号。

`tweenInfo1 {Position = UDim2.new(0.5, 0, 0.8, 0)}` 等同于 

tweenInfo1({Position = UDim2.new(0.5, 0, 0.8, 0)})


这是一个调用操作,但是由于 `TweenInfo` 值无法被调用而会失败。

而 `tweenInfo1, {Position = UDim2.new(0.5, 0, 0.8, 0)}` 是一个 `TweenInfo` 和一个 `table` 值的列表。 
2020-12-17 11:20:31