Files
block-game/ServerScriptService/CmdrCommands/ResyncNear.lua
2026-01-08 22:58:58 +02:00

49 lines
1.2 KiB
Lua

return {
Name = "resyncnear",
Aliases = {"resyncnearby"},
Description = "Resync chunks around a player's current chunk.",
Group = "Debug",
Args = {
{
Type = "player",
Name = "player",
Description = "Player to resync"
},
{
Type = "integer",
Name = "radius",
Description = "Radius around the player chunk",
Optional = true,
Default = 1
}
},
Run = function(context, player, radius)
local character = player.Character
if not character then
return "Player has no character"
end
local root = character:FindFirstChild("HumanoidRootPart")
if not root then
return "Player has no HumanoidRootPart"
end
local pos = root.Position
local cx = math.round(pos.X / 32)
local cy = math.round(pos.Y / 32)
local cz = math.round(pos.Z / 32)
local tickRemote = game:GetService("ReplicatedStorage"):WaitForChild("Tick")
local r = radius or 1
local count = 0
for y = -r, r do
for x = -r, r do
for z = -r, r do
tickRemote:FireClient(player, "C_R", cx + x, cy + y, cz + z, 0, 0, 0, 0)
count += 1
end
end
end
return ("Resync sent to %s (%d chunks around %d,%d,%d)"):format(player.Name, count, cx, cy, cz)
end
}