Roblox Ai
Key RequiredUniversal

Roblox Ai

Universal ScriptvobBoxvobBox 2.5K views 57 executesUpdated May 3, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•59 lines (1858 chars)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

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

local observing = false
local currentIndex = 1
local otherPlayers = {}

-- تحديث قائمة اللاعبين الآخرين
local function updateOtherPlayers()
	otherPlayers = {}
	for _, player in ipairs(Players:GetPlayers()) do
		if player ~= localPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
			table.insert(otherPlayers, player)
		end
	end
end

-- تفعيل/إلغاء تفعيل وضع المراقبة
local function toggleCamera()
	if not observing then
		updateOtherPlayers()
		if #otherPlayers > 0 then
			observing = true
			currentIndex = 1
			camera.CameraSubject = otherPlayers[currentIndex].Character:FindFirstChild("Humanoid")
		end
	else
		observing = false
		camera.CameraSubject = localPlayer.Character and localPlayer.Character:FindFirstChild("Humanoid") or localPlayer
	end
end

-- عند الضغط على J
UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then return end
	if input.KeyCode == Enum.KeyCode.J then
		toggleCamera()
	end
end)

-- تحديث الكاميرا إذا خرج اللاعب من اللعبة أو اختفى
RunService.RenderStepped:Connect(function()
	if observing then
		if not otherPlayers[currentIndex] or not otherPlayers[currentIndex].Character or not otherPlayers[currentIndex].Character:FindFirstChild("Humanoid") then
			updateOtherPlayers()
			if #otherPlayers > 0 then
				currentIndex = (currentIndex % #otherPlayers) + 1
				camera.CameraSubject = otherPlayers[currentIndex].Character:FindFirstChild("Humanoid")
			else
				observing = false
				camera.CameraSubject = localPlayer.Character and localPlayer.Character:FindFirstChild("Humanoid") or localPlayer
			end
		end
	end
end)

Features & Information

😱

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts