local HttpService = game:GetService("HttpService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui")
local isRecording = false
local data = {
map = {},
frames = {}
}
local heartbeatConn
local startTime = 0
local function serializePart(part)
return {
name = part.Name,
class = part.ClassName,
size = {part.Size.X, part.Size.Y, part.Size.Z},
pos = {part.Position.X, part.Position.Y, part.Position.Z},
rot = {part.Orientation.X, part.Orientation.Y, part.Orientation.Z},
color = part.BrickColor.Name,
mat = tostring(part.Material),
transparency = part.Transparency
}
end
local function captureMap()
for _, part in ipairs(workspace:GetDescendants()) do
if part:IsA("BasePart") and part.Anchored then
table.insert(data.map, serializePart(part))
end
end
end
local function captureFrame()
local char = LocalPlayer.Character
local root = char and char:FindFirstChild("HumanoidRootPart")
if not root then return end
table.insert(data.frames, {
t = tick(),
pos = {root.Position.X, root.Position.Y, root.Position.Z},
cam = {
pos = {Camera.CFrame.Position.X, Camera.CFrame.Position.Y, Camera.CFrame.Position.Z},
look = {Camera.CFrame.LookVector.X, Camera.CFrame.LookVector.Y, Camera.CFrame.LookVector.Z}
}
})
end
local function startRecording()
if isRecording then return end
isRecording = true
data = {map = {}, frames = {}}
startTime = tick()
captureMap()
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[Replay] Recording started";
Color = Color3.fromRGB(255, 0, 0);
})
heartbeatConn = RunService.Heartbeat:Connect(captureFrame)
end
local function stopRecording()
if not isRecording then return end
isRecording = false
if heartbeatConn then heartbeatConn:Disconnect() end
local base = data.frames[1] and data.frames[1].t or tick()
for _, f in ipairs(data.frames) do
f.t = f.t - base
end
local json = HttpService:JSONEncode(data)
local output = "return [[" .. json .. "]]"
writefile("ReplayData.lua", output)
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[Replay] Saved as ReplayData.lua";
Color = Color3.fromRGB(0, 255, 0);
})
end
UserInputService.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.F5 then
startRecording()
elseif input.KeyCode == Enum.KeyCode.F6 then
stopRecording()
end
end)
print("[Replay] Script loaded.")
To embed this project on your website, copy the following code and paste it into your website's HTML: