local InWork = true
local Cam = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Pos = game.Workspace:WaitForChild("Cams")
local UIS = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local CurrentCam = Pos:WaitForChild("Ordering 1")
local InfoT = TweenInfo.new(0.5, Enum.EasingStyle.Bounce)
function tweenCamera(part, toPlr)
if toPlr then
local tween = ts:Create(Cam, InfoT, {CFrame = Player.Character.PrimaryPart})
tween:Play()
tween.Completed:Wait()
Cam.CameraType = Enum.CameraType.Custom
else
Player.Character.PrimaryPart.CFrame = Cam.CFrame
while Cam.CameraType ~= Enum.CameraType.Scriptable do
Cam.CameraType = Enum.CameraType.Scriptable
end
ts:Create(Cam, InfoT, {CFrame = part.CFrame}):Play()
end
end
tweenCamera(CurrentCam, false)
-- For PC --
UIS.InputBegan:Connect(function(Inp, GPE)
if Inp.KeyCode == Enum.KeyCode.E then
local IndexCheck = #Pos:GetChildren()
if table.find(Pos:GetChildren(), CurrentCam) + 1 > IndexCheck then
print("q")
local NextIndex = 1
CurrentCam = Pos:GetChildren()[NextIndex]
tweenCamera(CurrentCam, false)
else
print("q")
local NextIndex = table.find(Pos:GetChildren(), CurrentCam) + 1
CurrentCam = Pos:GetChildren()[NextIndex]
tweenCamera(CurrentCam, false)
end
elseif Inp.KeyCode == Enum.KeyCode.Q then
local IndexCheck = 1
if table.find(Pos:GetChildren(), CurrentCam) - 1 < IndexCheck then
print("q")
local NextIndex = #Pos:GetChildren()
CurrentCam = Pos:GetChildren()[NextIndex]
tweenCamera(CurrentCam, false)
else
print("q")
local NextIndex = table.find(Pos:GetChildren(), CurrentCam) - 1
CurrentCam = Pos:GetChildren()[NextIndex]
tweenCamera(CurrentCam, false)
end
end
end)
Basically theres a change that when you start the game “Q” goes right and “E” goes left, but other times its the other way around…
I had no idea what i was doing when making this script because:
Im new to tweening
Ive never really messed with the camera
Im not the best with keycodes
Thanks for any help! If you need a video i could get one