Files
block-game/StarterGui/Game_UI/LocalScript.client.lua
2026-01-08 22:58:58 +02:00

74 lines
2.0 KiB
Lua

--!native
--!optimize 2
if not game:IsLoaded() then
game.Loaded:Wait()
end
local ui = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlacementState = require(ReplicatedStorage.Shared.PlacementState)
local objects = ReplicatedStorage:WaitForChild("Objects", 9e9)
objects:WaitForChild("MLLoaded", 9e9)
objects:WaitForChild("CSMLLoaded", 9e9)
local clientReady = ReplicatedStorage.Objects:WaitForChild("ClientReady", 5)
if clientReady and not clientReady.Value then
clientReady:GetPropertyChangedSignal("Value"):Wait()
end
local cd = ReplicatedStorage.Objects.ChunkDebug:Clone()
local sky = ReplicatedStorage.Objects.Sky:Clone()
local base = ReplicatedStorage.Objects.FakeBaseplate:Clone()
cd.Parent = game:GetService("Workspace"):FindFirstChildOfClass("Terrain")
sky.Parent = game:GetService("Workspace"):FindFirstChildOfClass("Terrain")
base.Parent = game:GetService("Workspace"):FindFirstChildOfClass("Terrain")
game:GetService("RunService").RenderStepped:Connect(function(dt)
local fps = math.round(1/dt)
pcall(function()
-- pos in chunks of 32 studs of char
local pos = game:GetService("Players").LocalPlayer.Character:GetPivot()
local chunk = {
x = math.round(pos.X/32),
y = math.round(pos.Y/32),
z = math.round(pos.Z/32)
}
if math.abs(chunk.x) == 0 then chunk.x = 0 end
if math.abs(chunk.y) == 0 then chunk.y = 0 end
if math.abs(chunk.z) == 0 then chunk.z = 0 end
local bpos = {
x = math.round(pos.X/4),
y = math.round(pos.Y/4),
z = math.round(pos.Z/4)
}
if math.abs(bpos.x) == 0 then bpos.x = 0 end
if math.abs(bpos.y) == 0 then bpos.y = 0 end
if math.abs(bpos.z) == 0 then bpos.z = 0 end
sky.CFrame = pos
local selected = PlacementState:GetSelected()
ui.DebugUpperText.Text = `Chunk {chunk.x} {chunk.y} {chunk.z}\nPos {bpos.x} {bpos.y} {bpos.z}\nSel {selected}\n<b>{fps} FPS</b>`
cd:PivotTo(CFrame.new(
chunk.x*32,
chunk.y*32,
chunk.z*32
))
base.CFrame = CFrame.new(
chunk.x*32,
-24,
chunk.z*32
)
end)
end)