Я пытаюсь сделать систему выбора сюжета для своей игры. Я хочу, чтобы графический интерфейс системы выбора сюжета отображался на экране после того, как я нажал кнопку воспроизведения. Однако мой сценарий снова и снова выдает «попытку вызвать значение 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