I’m trying to make an item shop where you can cycle the camera between items. Currently, it faces the first item for a second then resets the camera to the default position. Any way to fix this? Here’s the script:
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local CurrentCamera = Workspace.CurrentCamera
local Camera = game.Workspace.Camera
local LocalPlayer = Players.LocalPlayer
local Next = script.Parent:WaitForChild("Right")
local Previous = script.parent:WaitForChild("Left")
local CurrentItem = 1
local Finished = nil
wait()
Next.MouseButton1Click:connect(function()
CurrentCamera.CameraType = Enum.CameraType.Scriptable
if CurrentItem > 3 then
CurrentItem = 1
else
Finished = Workspace.Cameras[CurrentItem]
local TweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local Goal = {
CFrame = Finished.CFrame
}
local Tween = TweenService:Create(CurrentCamera, TweenInfo, Goal)
Tween:Play()
end
end)
I am not currently utilizing the CurrentItem variables I have in my script. I’m just trying to get the script to work first.