I am trying to make a plot selection system for my game. I want the plot selection system GUI to tween to the screen after I clicked the play button. However, my script keeps giving the "attempt to call a TweenInfo value" over and over again. Here is the full code.
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)
I tried using the TweenPosition code but it doesn't work either. Please help me.