local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local gui = script.Parent
if not player then return end
local cam = workspace.CurrentCamera
repeat task.wait() cam = workspace.CurrentCamera until cam
local camPart = workspace:FindFirstChild("MenuCam") or workspace:WaitForChild("MenuCam", 10)
if not camPart then return end
local playButton = gui:FindFirstChild("PlayButton", true) or gui:FindFirstChildWhichIsA("TextButton", true)
if not playButton then return end
gui.Enabled = true
local running = true
local camConn = RunService.RenderStepped:Connect(function()
if not running then return end
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = camPart.CFrame
end)
playButton.MouseButton1Click:Connect(function()
if not running then return end
running = false
if camConn then
camConn:Disconnect()
camConn = nil
end
local char = player.Character
if char and char:FindFirstChild("HumanoidRootPart") then
local hrp = char.HumanoidRootPart
local offset = hrp.CFrame.LookVector * -6 + Vector3.new(0, 3, 0)
local targetCFrame = CFrame.new(hrp.Position + offset, hrp.Position)
local duration = 0.6
local steps = math.max(1, math.floor(duration / (1/60)))
local start = cam.CFrame
for i = 1, steps do
local alpha = i / steps
cam.CFrame = start:Lerp(targetCFrame, alpha)
task.wait(1/60)
end
end
if not player.Character or not player.Character.Parent then
player:LoadCharacter()
end
cam.CameraType = Enum.CameraType.Custom
local char2 = player.Character or player.CharacterAdded:Wait()
local humanoid = char2 and char2:FindFirstChildOfClass("Humanoid")
if humanoid then
cam.CameraSubject = humanoid
end
gui.Enabled = false
end)