"attempt to call a TweenInfo value" 使用 Tween 服务时
"attempt to call a TweenInfo value" when using Tween Service
我正在尝试为我的游戏制作剧情选择系统。我希望在单击播放按钮后,情节选择系统 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 代码,但它也不起作用。请帮助我。
local tween1 = TweenService:Create(Frame, tweenInfo1 {Position = UDim2.new(0.5, 0, 0.8, 0)})
在 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
值的列表
我正在尝试为我的游戏制作剧情选择系统。我希望在单击播放按钮后,情节选择系统 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 代码,但它也不起作用。请帮助我。
local tween1 = TweenService:Create(Frame, tweenInfo1 {Position = UDim2.new(0.5, 0, 0.8, 0)})
在 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
值的列表