trying to make a top down camera, and tried adding a smooth scrolling with tweens but it doesnt really work and spazzes out basically
-- Variables
local RunService = game:GetService("RunService")
local uis = game:GetService('UserInputService')
local Ts = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
local camera = game.Workspace.CurrentCamera
local mouse = player:GetMouse()
local View = 25
local LastView = nil
-- Main
wait(3)
camera.CameraType = Enum.CameraType.Scriptable
mouse.WheelForward:Connect(function()
View = math.clamp((View - 5), 10, 50)
end)
mouse.WheelBackward:Connect(function()
View = math.clamp((View + 5), 10, 50)
end)
RunService.Heartbeat:Connect(function()
--camera.CFrame = CFrame.new(CFrame.new(0,0,0).Position + Vector3.new(0,math.clamp(View,10,50),0))
camera.CFrame *= CFrame.Angles(math.rad(-90),0,0)
if View ~= LastView then
Ts:Create(camera, TweenInfo.new(.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),{
CFrame = CFrame.new(CFrame.new(0,0,0).Position + Vector3.new(0,math.clamp(View,10,50),0))}):Play()
LastView = View
else
LastView = View
end
end)