AFKTime
Key RequiredUniversal

AFKTime

Universal ScriptvobBoxvobBox 1.3K views 6 executesUpdated May 5, 2025
2.5/ 5(2 votes)
1150% Positive
Lua Script•129 lines (3649 chars)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

local idleTime = 0
local AFKTime = 20  -- الوقت الذي يجب أن يقف فيه اللاعب دون حركة لتفعيل السكربت
local switchDelay = 5  -- التأخير بين انتقالات الكاميرا
local switching = false

local orbitAngle = 0
local lastTween = nil

-- احصل على جذر اللاعب (HumanoidRootPart)
local function getPlayerRoot()
	local success, result = pcall(function()
		local character = player.Character or player.CharacterAdded:Wait()
		return character:WaitForChild("HumanoidRootPart")
	end)
	return success and result or nil
end

-- اختر لاعب عشوائي غير اللاعب الحالي
local function getRandomOtherPlayer()
	local others = {}
	for _, p in ipairs(Players:GetPlayers()) do
		if p ~= player and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then
			table.insert(others, p)
		end
	end
	if #others > 0 then
		return others[math.random(1, #others)]
	end
	return nil
end

-- تابع اللاعب بحركة كاميرا ناعمة وجميلة
local function followPlayerWithOrbit(target)
	if not target or not target.Character then return end
	local hrp = target.Character:WaitForChild("HumanoidRootPart")

	RunService:UnbindFromRenderStep("FollowTarget")

	local angleRad = math.rad(math.random(0, 360))
	local radius = 14
	local height = 6
	local offset = Vector3.new(math.sin(angleRad) * radius, height, math.cos(angleRad) * radius)
	local targetPos = hrp.Position
	local newCFrame = CFrame.new(targetPos + offset, targetPos)

	local tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

	-- حرك الكاميرا نفسها مع تأثير FOV ناعم
	local tween = TweenService:Create(camera, tweenInfo, {CFrame = newCFrame, FieldOfView = 40 + math.random(-10, 10)})
	tween:Play()

	-- بعدها تدور الكاميرا باستمرار حول اللاعب
	task.wait(1.5)
	RunService:BindToRenderStep("FollowTarget", Enum.RenderPriority.Camera.Value + 1, function()
		if not target.Character or not target.Character:FindFirstChild("HumanoidRootPart") then return end

		orbitAngle += 0.3
		local angle = math.rad(orbitAngle)
		local dynamicOffset = Vector3.new(math.sin(angle) * radius, height, math.cos(angle) * radius)
		local orbitCFrame = CFrame.new(hrp.Position + dynamicOffset, hrp.Position)

		camera.CFrame = orbitCFrame
	end)
end

-- تفعيل الكاميرا الحرة والانتقال بين اللاعبين
local function startSwitching()
	switching = true
	camera.CameraType = Enum.CameraType.Scriptable

	-- زووم ناعم
	local fovTween = TweenService:Create(camera, TweenInfo.new(2, Enum.EasingStyle.Sine), {
		FieldOfView = 40
	})
	fovTween:Play()

	task.spawn(function()
		while switching do
			local target = getRandomOtherPlayer()
			if target then
				RunService:UnbindFromRenderStep("FollowTarget")
				followPlayerWithOrbit(target)
			end
			task.wait(switchDelay)
		end
	end)
end

-- إيقاف الكاميرا والعودة للوضع الطبيعي
local function resetCamera()
	RunService:UnbindFromRenderStep("FollowTarget")
	camera.CameraType = Enum.CameraType.Custom
	camera.FieldOfView = 70
	switching = false
end

-- تتبع حركة اللاعب لمراقبة الوضع AFK
RunService.RenderStepped:Connect(function()
	local root = getPlayerRoot()
	if not root then return end

	local velocity = root.Velocity.Magnitude

	if velocity < 0.1 then
		idleTime += RunService.RenderStepped:Wait()
	else
		idleTime = 0
		if switching then
			resetCamera()
		end
	end

	if idleTime >= AFKTime and not switching then
		startSwitching()
	end
end)

-- تجاهل إعادة التجسد
player.CharacterAdded:Connect(function()
	if switching then return end
	idleTime = 0
end)

Features & Information

AFKTime

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts