local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local players = game:GetService("Players"):GetPlayers()
local currentPlayerIndex = 1
local lastTween = nil
local stopFlag = false
local SAMPLE_HEAD_POS = Vector3.new(56.99, 4.489, 480.976)
local followIndoorCount = 0
local cinematicOutdoorCount = 0
local shotCloseCount = 0
local cinematic3ShotCount = 0
local shotCloseFHeadCount = 0
local yReductionFactor = 1.1

-- متغير لتحديد مدة الحركة عند استخدام زر الفاصلة
local movementDurationForComma = 5  -- يمكنك تعديل هذا الرقم حسب الرغبة

local function addOffsetToData(data, offsetCFrame)
    local newData = {}
    for i, v in ipairs(data) do
        newData[i] = {
            CFrame = v.CFrame * offsetCFrame,
            Seconds = v.Seconds,
            Style = v.Style
        }
    end
    return newData
end

local function reduceYInCFrame(cframe, factor)
    local pos = cframe.Position
    local reducedPos = Vector3.new(pos.X, pos.Y * factor, pos.Z)
    return CFrame.new(reducedPos) * cframe - pos
end

-- ... (باقي الكود لإنشاء GUI)


local CameraCTR = Instance.new("ScreenGui")
CameraCTR.Name = "CameraCTR"
CameraCTR.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
CameraCTR.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

local BigParentFrame = Instance.new("Frame")
BigParentFrame.Name = "BigParentFrame"
BigParentFrame.Parent = CameraCTR
BigParentFrame.BackgroundTransparency = 1
BigParentFrame.Position = UDim2.new(0.0404234827, 0, 0.0652503818, 0)
BigParentFrame.Size = UDim2.new(0, 247, 0, 577)

local Framesmall = Instance.new("Frame")
Framesmall.Name = "Framesmall"
Framesmall.Parent = BigParentFrame
Framesmall.BackgroundColor3 = Color3.new(0.333333, 0.333333, 0.498039)
Framesmall.BorderSizePixel = 0
Framesmall.Position = UDim2.new(0.0157, 0, -0.00432, 0)
Framesmall.Size = UDim2.new(0, 247, 0, 475)

local UICorner_2 = Instance.new("UICorner")
UICorner_2.Parent = Framesmall
UICorner_2.CornerRadius = UDim.new(0, 15)

local UIListLayout = Instance.new("UIListLayout")
local UIPadding = Instance.new("UIPadding")

UIListLayout.Parent = Framesmall
UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
UIListLayout.Padding = UDim.new(0, 5)

UIPadding.Parent = Framesmall
UIPadding.PaddingTop = UDim.new(0.25, 0)

local ShotCloseFHead = Instance.new("TextButton")
ShotCloseFHead.Name = "ShotCloseFHead"
ShotCloseFHead.Parent = Framesmall
ShotCloseFHead.BackgroundColor3 = Color3.new(0.670588, 0.890196, 1)
ShotCloseFHead.BorderSizePixel = 0
ShotCloseFHead.Position = UDim2.new(0.0931, 0, 0.1213, 0)
ShotCloseFHead.Size = UDim2.new(0, 200, 0, 50)
ShotCloseFHead.Font = Enum.Font.SourceSans
ShotCloseFHead.Text = "Shot Close Head View"
ShotCloseFHead.TextColor3 = Color3.new(0.152941, 0.152941, 0.227451)
ShotCloseFHead.TextSize = 14

local UICorner_3 = Instance.new("UICorner")
UICorner_3.Parent = ShotCloseFHead
UICorner_3.CornerRadius = UDim.new(0, 15)

local CameraShotClose = Instance.new("TextButton")
CameraShotClose.Name = "CameraShotClose"
CameraShotClose.Parent = Framesmall
CameraShotClose.BackgroundColor3 = Color3.new(0.670588, 0.670588, 1)
CameraShotClose.BorderSizePixel = 0
CameraShotClose.Position = UDim2.new(0.0931, 0, 0.2409, 0)
CameraShotClose.Size = UDim2.new(0, 200, 0, 50)
CameraShotClose.Font = Enum.Font.SourceSans
CameraShotClose.Text = "Camera Shot Close"
CameraShotClose.TextColor3 = Color3.new(0.152941, 0.152941, 0.227451)
CameraShotClose.TextSize = 14

local UICorner_4 = Instance.new("UICorner")
UICorner_4.Parent = CameraShotClose
UICorner_4.CornerRadius = UDim.new(0, 15)

local CameraCinematicFollowInPl = Instance.new("TextButton")
CameraCinematicFollowInPl.Name = "CameraCinematicFollowInPl"
CameraCinematicFollowInPl.Parent = Framesmall
CameraCinematicFollowInPl.BackgroundColor3 = Color3.new(0.670588, 0.890196, 1)
CameraCinematicFollowInPl.BorderSizePixel = 0
CameraCinematicFollowInPl.Position = UDim2.new(0.0931, 0, 0.355, 0)
CameraCinematicFollowInPl.Size = UDim2.new(0, 200, 0, 50)
CameraCinematicFollowInPl.Font = Enum.Font.SourceSans
CameraCinematicFollowInPl.Text = "Camera Cinematic Indoor"
CameraCinematicFollowInPl.TextColor3 = Color3.new(0.152941, 0.152941, 0.227451)
CameraCinematicFollowInPl.TextSize = 14

local UICorner_5 = Instance.new("UICorner")
UICorner_5.Parent = CameraCinematicFollowInPl
UICorner_5.CornerRadius = UDim.new(0, 15)

local CameraCinematicOutdoor = Instance.new("TextButton")
CameraCinematicOutdoor.Name = "CameraCinematicOutdoor"
CameraCinematicOutdoor.Parent = Framesmall
CameraCinematicOutdoor.BackgroundColor3 = Color3.new(0.670588, 0.670588, 1)
CameraCinematicOutdoor.BorderSizePixel = 0
CameraCinematicOutdoor.Position = UDim2.new(0.0931, 0, 0.470, 0)
CameraCinematicOutdoor.Size = UDim2.new(0, 200, 0, 50)
CameraCinematicOutdoor.Font = Enum.Font.SourceSans
CameraCinematicOutdoor.Text = "Camera Cinematic Outdoor"
CameraCinematicOutdoor.TextColor3 = Color3.new(0.152941, 0.152941, 0.227451)
CameraCinematicOutdoor.TextSize = 14

local UICorner_6 = Instance.new("UICorner")
UICorner_6.Parent = CameraCinematicOutdoor
UICorner_6.CornerRadius = UDim.new(0, 15)

local CameraCinematic3Shot = Instance.new("TextButton")
CameraCinematic3Shot.Name = "CameraCinematic3Shot"
CameraCinematic3Shot.Parent = Framesmall
CameraCinematic3Shot.BackgroundColor3 = Color3.new(0.670588, 0.890196, 1)
CameraCinematic3Shot.BorderSizePixel = 0
CameraCinematic3Shot.Position = UDim2.new(0.0931, 0, 0.585, 0)
CameraCinematic3Shot.Size = UDim2.new(0, 200, 0, 50)
CameraCinematic3Shot.Font = Enum.Font.SourceSans
CameraCinematic3Shot.Text = "Camera Cinematic 3 Shot"
CameraCinematic3Shot.TextColor3 = Color3.new(0.152941, 0.152941, 0.227451)
CameraCinematic3Shot.TextSize = 14

local UICorner_7 = Instance.new("UICorner")
UICorner_7.Parent = CameraCinematic3Shot
UICorner_7.CornerRadius = UDim.new(0, 15)

local StopCameraAn = Instance.new("TextButton")
StopCameraAn.Name = "StopCameraAn"
StopCameraAn.Parent = Framesmall
StopCameraAn.BackgroundColor3 = Color3.new(0.670588, 0.670588, 1)
StopCameraAn.BorderSizePixel = 0
StopCameraAn.Position = UDim2.new(0.0931, 0, 0.700, 0)
StopCameraAn.Size = UDim2.new(0, 200, 0, 50)
StopCameraAn.Font = Enum.Font.SourceSans
StopCameraAn.Text = "Stop Camera"
StopCameraAn.TextColor3 = Color3.new(0.152941, 0.152941, 0.227451)
StopCameraAn.TextSize = 14

local UICorner_8 = Instance.new("UICorner")
UICorner_8.Parent = StopCameraAn
UICorner_8.CornerRadius = UDim.new(0, 15)

local Xbuttonexit = Instance.new("TextButton")
Xbuttonexit.Name = "Xbuttonexit"
Xbuttonexit.Parent = BigParentFrame
Xbuttonexit.BackgroundColor3 = Color3.new(0.333333, 0.333333, 0.498039)
Xbuttonexit.BorderSizePixel = 0
Xbuttonexit.Position = UDim2.new(1.0421052, 0, 0, 0)
Xbuttonexit.Size = UDim2.new(0, 35, 0, 40)
Xbuttonexit.Font = Enum.Font.FredokaOne
Xbuttonexit.Text = "X"
Xbuttonexit.TextColor3 = Color3.new(1, 1, 1)
Xbuttonexit.TextScaled = true
Xbuttonexit.TextSize = 14
Xbuttonexit.TextWrapped = true

local UICorner_9 = Instance.new("UICorner")
UICorner_9.Parent = Xbuttonexit
UICorner_9.CornerRadius = UDim.new(0, 50)

local CRightButton = Instance.new("TextButton")
CRightButton.Name = "CRightButton"
CRightButton.Parent = BigParentFrame
CRightButton.BackgroundColor3 = Color3.new(0.670588, 0.670588, 1)
CRightButton.BorderColor3 = Color3.new(0, 0, 0)
CRightButton.BorderSizePixel = 0
CRightButton.Position = UDim2.new(0.781376541, 0, 0.0797227025, 0)
CRightButton.Size = UDim2.new(0, 34, 0, 37)
CRightButton.Font = Enum.Font.SourceSans
CRightButton.Text = ">"
CRightButton.TextColor3 = Color3.new(0, 0, 0)
CRightButton.TextSize = 14

local UICorner_10 = Instance.new("UICorner")
UICorner_10.Parent = CRightButton
UICorner_10.CornerRadius = UDim.new(0, 50)

local CLefttButton = Instance.new("TextButton")
CLefttButton.Name = "CLefttButton"
CLefttButton.Parent = BigParentFrame
CLefttButton.BackgroundColor3 = Color3.new(0.670588, 0.670588, 1)
CLefttButton.BorderColor3 = Color3.new(0, 0, 0)
CLefttButton.BorderSizePixel = 0
CLefttButton.Position = UDim2.new(0.109311745, 0, 0.0797227025, 0)
CLefttButton.Size = UDim2.new(0, 34, 0, 37)
CLefttButton.Font = Enum.Font.SourceSans
CLefttButton.Text = "<"
CLefttButton.TextColor3 = Color3.new(0, 0, 0)
CLefttButton.TextSize = 14

local UICorner_12 = Instance.new("UICorner")
UICorner_12.Parent = CLefttButton
UICorner_12.CornerRadius = UDim.new(0, 50)

local ImagePlayerCT = Instance.new("ImageLabel")
ImagePlayerCT.Name = "ImagePlayerCT"
ImagePlayerCT.Parent = BigParentFrame
ImagePlayerCT.BackgroundColor3 = Color3.new(1, 1, 1)
ImagePlayerCT.BorderColor3 = Color3.new(0, 0, 0)
ImagePlayerCT.BorderSizePixel = 0
ImagePlayerCT.Position = UDim2.new(0.400809705, 0, -0.045060657, 0)
ImagePlayerCT.Size = UDim2.new(0, 54, 0, 54)
ImagePlayerCT.Image = "rbxasset://textures/ui/GuiImagePlaceholder.png"

local UICorner_13 = Instance.new("UICorner")
UICorner_13.Parent = ImagePlayerCT
UICorner_13.CornerRadius = UDim.new(0, 50)

local CnamePlayer = Instance.new("TextLabel")
CnamePlayer.Name = "CnamePlayer"
CnamePlayer.Parent = BigParentFrame
CnamePlayer.BackgroundColor3 = Color3.new(0.45098, 0.45098, 0.670588)
CnamePlayer.BorderColor3 = Color3.new(0, 0, 0)
CnamePlayer.BorderSizePixel = 0
CnamePlayer.Position = UDim2.new(0.283728719, 0, 0.0690000057, 0)
CnamePlayer.Size = UDim2.new(0, 113, 0, 50)
CnamePlayer.Font = Enum.Font.SourceSans
CnamePlayer.Text = "Name Player"
CnamePlayer.TextColor3 = Color3.new(1, 1, 1)
CnamePlayer.TextSize = 14

local UICorner_11 = Instance.new("UICorner")
UICorner_11.Parent = CnamePlayer
UICorner_11.CornerRadius = UDim.new(0, 15)
local function updatePlayerInfo()
    local player = players[currentPlayerIndex]
    if player then
        CnamePlayer.Text = player.Name
        ImagePlayerCT.Image = "rbxthumb://type=AvatarHeadShot&id=" .. player.UserId .. "&w=150&h=150"
    end
end

CRightButton.MouseButton1Click:Connect(function()
    currentPlayerIndex = (currentPlayerIndex % #players) + 1
    updatePlayerInfo()
end)

CLefttButton.MouseButton1Click:Connect(function()
    currentPlayerIndex = ((currentPlayerIndex - 2) % #players) + 1
    updatePlayerInfo()
end)

local function adjustCFrame(sampleCFrame)
    local player = players[currentPlayerIndex]
    if player and player.Character and player.Character:FindFirstChild("Head") then
        local head = player.Character.Head
        local offset = sampleCFrame.Position - SAMPLE_HEAD_POS
        local a, b, c = sampleCFrame:ToOrientation()
        return head.CFrame * CFrame.new(offset) * CFrame.Angles(a, b, c)
    else
        return sampleCFrame
    end
end

local function playCameraTween(data, useCommaDuration)
    stopFlag = false
    if lastTween then
        lastTween:Cancel()
    end
    camera.CameraType = Enum.CameraType.Scriptable
    if #data > 0 then
        camera.CFrame = reduceYInCFrame(adjustCFrame(data[1].CFrame), yReductionFactor)
        for i = 2, #data do
            if stopFlag then break end
            local v = data[i]
            local adjustedCFrame = reduceYInCFrame(adjustCFrame(v.CFrame), yReductionFactor)
            local duration = useCommaDuration and movementDurationForComma or (v.Seconds * 2)
            local tween = TweenService:Create(
                camera,
                TweenInfo.new(duration, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
                {CFrame = adjustedCFrame}
            )
            lastTween = tween
            tween:Play()
            tween.Completed:Wait()
        end
    end
end

local allMovements = {
    {button = ShotCloseFHead, func = function() 
        shotCloseFHeadCount = shotCloseFHeadCount + 1
        return {
            {CFrame = CFrame.new(56.958, 4.345*0.8, 479.428) * CFrame.Angles(math.rad(-12.772), math.rad(-2.129), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(57, 4.216*0.8, 478.985) * CFrame.Angles(math.rad(-8.475), math.rad(-0.983), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(56.8, 4.219*0.8, 479.359) * CFrame.Angles(math.rad(-8.639), math.rad(-0.749), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(56.798, 4.749*0.8, 479.382) * CFrame.Angles(math.rad(-17.803), math.rad(-2.426), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(59.356, 4.111*0.8, 480.291) * CFrame.Angles(math.rad(-12.411), math.rad(29.088), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(61.703, 4.557*0.8, 483.927) * CFrame.Angles(math.rad(-15.467), math.rad(41.421), 0), Seconds = 15, Style = Enum.EasingStyle.Sine}
        }
    end},
    {button = CameraShotClose, func = function() 
        shotCloseCount = shotCloseCount + 1
        return {
            {CFrame = CFrame.new(62.548, 5.61*0.8, 466.545) * CFrame.Angles(math.rad(-7.761), math.rad(158.006), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(58.318, 4.07*0.8, 477.019) * CFrame.Angles(math.rad(-7.761), math.rad(158.006), 0), Seconds = 15, Style = Enum.EasingStyle.Sine}
        }
    end},
    {button = CameraCinematicFollowInPl, func = function() 
        followIndoorCount = followIndoorCount + 1
        return {
            {CFrame = CFrame.new(48.004, 5.505*0.8, 463.989) * CFrame.Angles(math.rad(-8.662), math.rad(-149.596), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(52.106, 4.532*0.8, 473.54) * CFrame.Angles(math.rad(-13.763), math.rad(-131.994), 0), Seconds = 15, Style = Enum.EasingStyle.Sine}
        }
    end},
    {button = CameraCinematic3Shot, func = function() 
        cinematic3ShotCount = cinematic3ShotCount + 1
        return {
            {CFrame = CFrame.new(62.789, 3.602*0.8, 472.822) * CFrame.Angles(math.rad(-6.561), math.rad(132.006), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(65.034, 3.821*0.8, 478.926) * CFrame.Angles(math.rad(-7.76), math.rad(87.197), 0), Seconds = 15, Style = Enum.EasingStyle.Sine},
            {CFrame = CFrame.new(62.496, 3.821*0.8, 483.961) * CFrame.Angles(math.rad(-7.76), math.rad(45.599), 0), Seconds = 15, Style = Enum.EasingStyle.Sine}
        }
    end}
}

local function hideGUIAndDelayTween(data)
    BigParentFrame.Visible = false
    wait(0.2) -- إخفاء الـ GUI لمدة 0.2 ثانية قبل بدء الحركة
    playCameraTween(data)
end

ShotCloseFHead.MouseButton1Click:Connect(function()
    if allMovements[1] then
        hideGUIAndDelayTween(allMovements[1].func())
    end
end)

CameraShotClose.MouseButton1Click:Connect(function()
    if allMovements[2] then
        hideGUIAndDelayTween(allMovements[2].func())
    end
end)

CameraCinematicFollowInPl.MouseButton1Click:Connect(function()
    if allMovements[3] then
        hideGUIAndDelayTween(allMovements[3].func())
    end
end)

CameraCinematic3Shot.MouseButton1Click:Connect(function()
    if allMovements[4] then
        hideGUIAndDelayTween(allMovements[4].func())
    end
end)

local function playAllMovementsExceptOutdoor()
    BigParentFrame.Visible = false
    wait(0.2) -- يمكنك ضبط هذا الوقت حسب الرغبة

    for i = 1, #allMovements do
        if allMovements[i] then
            playCameraTween(allMovements[i].func(), true) -- تمرير true لاستخدام مدة الحركة المحددة
            wait(1) -- إضافة توقف بين الحركات
        end
    end
end

BigParentFrame.Active = true
BigParentFrame.Draggable = false

BigParentFrame.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        local dragging = true
        local dragInput, dragStart, startPos
        dragInput = input
        dragStart = input.Position
        startPos = BigParentFrame.Position
        dragInput.Changed:Connect(function()
            if dragInput.UserInputState == Enum.UserInputState.End then
                dragging = false
            end
        end)
        while dragging do
            wait()
            local delta = input.Position - dragStart
            BigParentFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
        end
    end
end)

Xbuttonexit.MouseButton1Click:Connect(function()
    BigParentFrame.Visible = false
end)

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    if not gameProcessedEvent then
        if input.KeyCode == Enum.KeyCode.L then
            BigParentFrame.Visible = not BigParentFrame.Visible
        elseif input.KeyCode == Enum.KeyCode.Comma then
            playAllMovementsExceptOutdoor()
        end
    end
end)

StopCameraAn.MouseButton1Click:Connect(function()
    stopFlag = true
    if lastTween then
        lastTween:Cancel()
    end
    camera.CameraType = Enum.CameraType.Custom
    BigParentFrame.Visible = true
end)

-- استدعاء أول معلومات اللاعب عند بدء السكربت
updatePlayerInfo()
هذه النسخة تعمل لكن اريد اضيف هذه الميزة
جيد اصبحنا اقرب الي النتيجة التي اريدها 
اريد عندما اضغط علي زر ايقاف الحركة 
ان يقوم بأيقاف كل الحركات حتي و لو كانت الحركات كلها من 
زر ,
عندما اضغط فعلا يقوم بأيقاف الحركة لكن الحركة التي شغالة و عشان الزر بيقوم بتشغيل كل الحركات الي الاوت دور 
فينتقل للي بعدها و بعدها و هكذا 
و هذا الذي لا اريده اريد عندما اضغط ان يقوم بأيقاف كافة الحركات الي شغالة او الي هتشتغل من خلال زر ,
يعني يوقف سلسلة تشغيل حركة الكاميرة من زر , 
بمعني يقوم بأيقاف الحركة الحالية و التي سوف تأتي بعدها من التسلسل الحركات 
يعني اكنني لم اضغط علي الزر من الاساس