(edit)
changed it so the character doesnt bug out but now after a bit the character cant move at all
new script
-- Variables
local RunService = game:GetService("RunService")
local uis = game:GetService('UserInputService')
local Ts = game:GetService("TweenService")
local Cas = game:GetService("ContextActionService")
-- math and stuff --
local clamp = math.clamp
local cfa = CFrame.Angles
local rad = math.rad
local cfn = CFrame.new
local v3n = Vector3.new
-- --
local player = game:GetService("Players").LocalPlayer
local camera = game.Workspace.CurrentCamera
local mouse = player:GetMouse()
local Debug = false
local View = 25
local MinView = 10
local MaxView = 50
local DownCF = cfa(rad(-90),0,0)
local LastView
local Connection1
local LastCFrame
local part1 = Instance.new("Part", workspace); part1.Anchored = true; part1.Size = Vector3.new(1,1,1); part1.CanCollide = false; part1.CanQuery = false; part1.CanTouch = false
local part2 = part1:Clone(); part2.Parent = workspace
local part3 = part1:Clone(); part3.Parent = workspace
part1.Transparency = 0.8; part2.Transparency = 0.8; part3.Transparency = 0.8;
part1.Color = Color3.new(1,0,0); part2.Color = Color3.new(0,1,0); part3.Color = Color3.new(0,0,1)
-- Functions
local function Main()
local Character = player.Character or player.CharacterAdded:Wait()
local rp = Character:WaitForChild("HumanoidRootPart")
Connection1 = RunService.Heartbeat:Connect(function()
local tH = (clamp(View,MinView,MaxView))/5
local mP = mouse.Hit.Position
local tP = (rp.Position + mP) / 2
local xClamp = clamp(tP.X, -tH + rp.Position.X, tH + rp.Position.X)
local zClamp = clamp(tP.Z, -tH + rp.Position.Z, tH + rp.Position.Z)
local CamCFrame = cfn(xClamp, rp.Position.Y + clamp(View, MinView, MaxView), zClamp) * DownCF
if Debug then
part1.Position = mP
part2.Position = tP
part3.Position = CamCFrame.Position - v3n(0, clamp(View, MinView, MaxView), 0)
end
rp.CFrame = CFrame.lookAt(rp.Position, v3n(mP.X, rp.Position.Y, mP.Z))
Ts:Create(camera, TweenInfo.new(.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),{CFrame = CamCFrame}):Play()
end)
end
-- Main
wait(2)
camera.CameraType = Enum.CameraType.Scriptable
mouse.WheelForward:Connect(function()
View = clamp((View - 4), 10, 50)
end)
mouse.WheelBackward:Connect(function()
View = clamp((View + 4), 10, 50)
end)
Main()
(edit 2)
seems to be something about the line
Ts:Create(camera, TweenInfo.new(.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),{CFrame = CamCFrame}):Play()
that just randomly stops the player from moving, not sure why though
(edit 3)
its breaking due to something with setting the camera’s cframe
tried changing the cframe without the tween and it breaks the character’s movement instantly