if not game:IsLoaded() then game.Loaded:Wait() end
local localPlayer = game.Players.LocalPlayer
local localChar = localPlayer.Character
local localCamPart = game.ReplicatedStorage.LocalCameraPart
localCamPart.Parent = game.Workspace
localCamPart.Transparency = 1
localCamPart.Anchored = true
local camera = game.Workspace.CurrentCamera
local camDistance = 50
local minCamDis = 3
local maxCamDis = 103
game:GetService('RunService').Heartbeat:Connect(function()
local humanoidRootPart = nil
local humanoid = nil
camDistance = math.clamp(camDistance, minCamDis, maxCamDis)
if localPlayer.Character ~= nil then
humanoidRootPart, humanoid = localPlayer.Character:FindFirstChild('HumanoidRootPart'), localPlayer.Character:FindFirstChild('Humanoid')
localCamPart.Position = humanoidRootPart.Position+Vector3.new(0, camDistance, 0)
localCamPart.CFrame = CFrame.lookAt(localCamPart.Position, humanoidRootPart.Position)
local distanceFactor = camDistance/maxCamDis
humanoid.WalkSpeed = distanceFactor*64 > 8 and distanceFactor*64 or 8
end
if camera.CameraType == Enum.CameraType.Custom then camera.CameraType = Enum.CameraType.Scriptable end
camera.CFrame = localCamPart.CFrame
end)
game:GetService('UserInputService').InputChanged:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.MouseWheel then
camDistance = camDistance - input.Position.Z*2
end
end
end)
Why can’t I move my character when this script is active?
(not sure if others experience the same thing)