0% found this document useful (0 votes)
11 views5 pages

Message

Uploaded by

bendril546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Message

Uploaded by

bendril546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

-- Asset ID at the top for clarity

local assetId = 'rbxassetid://318053587'

-- Main script: All functionality in a single script


local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")

-- Validate LocalScript context


local player = Players.LocalPlayer
if not player then
error("Script must be executed as a LocalScript (LocalPlayer required)")
end

local mouse = player:GetMouse()


local charter = player.Character or player.CharacterAdded:Wait()
local parent

-- Validate the build area


do
local privateAreas = Workspace:FindFirstChild("Private Building Areas")
if not privateAreas then
error("Private Building Areas not found in Workspace")
end

local buildArea = privateAreas:FindFirstChild(tostring(player) .. "BuildArea")


if not buildArea then
error("BuildArea not found for player: " .. tostring(player))
end

parent = buildArea:FindFirstChild("Build")
if not parent then
error("Build parent area not found for player: " .. tostring(player))
end
end

-- BuildManager Module Simulation


local BuildManager = {}

function BuildManager.LoadBuildModel(assetId)
local build
local success, result = pcall(function()
return game:GetObjects(assetId)[1]
end)
if success and result then
build = result
else
error("Failed to load asset with ID: " .. assetId)
end
return build
end

function BuildManager.PrepareBuild(build, parent)


for _, v in pairs(build:GetDescendants()) do
if v:IsA("BasePart") then
local success, err = pcall(function()
v.Anchored = true
v.Transparency = 0.5
v.Parent = build
end)
if not success then
warn("Error anchoring or parenting part: " .. err)
end
end
end
build.Parent = parent
end

function BuildManager.CreateFakeBuild(build, character)


local fakebuild = build:Clone()
fakebuild.Parent = character
return fakebuild
end

function BuildManager.MoveFakeBuild(fakebuild, mouse)


local success, err = pcall(function()
fakebuild:MoveTo(mouse.Hit.p)
end)
if not success then
warn("Error moving fakebuild: " .. err)
end
end

-- PartDetails Module Simulation


local PartDetails = {}

function PartDetails.GetDetails(part)
if part:IsA("Part") then
local g = {}
if part.Shape == Enum.PartType.Block then
g.Type = "Normal"
elseif part:IsA("TrussPart") then
g.Type = "Truss"
elseif part:IsA("CornerWedgePart") then
g.Type = "Corner"
elseif part:IsA("Part") and part.Shape == Enum.PartType.Cylinder then
g.Type = "Cylinder"
elseif part:IsA("Part") and part.Shape == Enum.PartType.Ball then
g.Type = "Ball"
elseif part:IsA("Seat") then
g.Type = "Seat"
elseif part:IsA("VehicleSeat") then
g.Type = "Vehicle Seat"
elseif part:IsA("SpawnLocation") then
g.Type = "Spawn"
end
g.Color = part.Color
return g
end
end

-- PartBuilder Module Simulation with Mesh Handling


local PartBuilder = {}

function PartBuilder.RecreatePart(fakepart, charter, parent)


if fakepart:IsA("Part") then
local success, err = pcall(function()
local details = PartDetails.GetDetails(fakepart)
if details then
-- Create the part on the server
local part = charter["Building
Tools"].SyncAPI.ServerEndpoint:InvokeServer("CreatePart", details.Type,
fakepart.CFrame, parent)
if not part then
error("Failed to create part on server.")
end
print("Part created: ", part.Name, " Size: ", fakepart.Size)

-- Apply properties individually


charter["Building
Tools"].SyncAPI.ServerEndpoint:InvokeServer("SyncResize", {
[1] = {
["Part"] = part,
["CFrame"] = fakepart.CFrame,
["Size"] = fakepart.Size,
}
})
print("Resized part to: ", fakepart.Size)

charter["Building
Tools"].SyncAPI.ServerEndpoint:InvokeServer("SyncColor", {
[1] = {
["Part"] = part,
["UnionColoring"] = true,
["Color"] = details.Color,
}
})
print("Color updated: ", details.Color)

charter["Building
Tools"].SyncAPI.ServerEndpoint:InvokeServer("SyncMaterial", {
[1] = {
["Part"] = part,
["Material"] = fakepart.Material,
}
})
print("Material updated: ", fakepart.Material)

charter["Building
Tools"].SyncAPI.ServerEndpoint:InvokeServer("SyncSurface", {
[1] = {
["Part"] = part,
["Surfaces"] = {
["Top"] = fakepart.TopSurface,
["Front"] = fakepart.FrontSurface,
["Bottom"] = fakepart.BottomSurface,
["Right"] = fakepart.RightSurface,
["Left"] = fakepart.LeftSurface,
["Back"] = fakepart.BackSurface,
},
}
})
print("Surfaces updated.")

-- Handle Mesh if it exists


if fakepart:FindFirstChildWhichIsA("FileMesh") then
local fakemesh = fakepart:FindFirstChildWhichIsA("FileMesh")
local meshid = fakemesh.MeshId
local textureid = fakemesh.TextureId

-- Create the mesh on the server


local mesh = charter["Building
Tools"].SyncAPI.ServerEndpoint:InvokeServer("CreateMeshes", {
[1] = { Part = part }
})[1]
print("Mesh created.")

-- Sync MeshType to File


charter["Building
Tools"].SyncAPI.ServerEndpoint:InvokeServer("SyncMesh", {
[1] = { ["Part"] = mesh.Parent, ["MeshType"] =
Enum.MeshType.FileMesh }
})
print("MeshType updated to FileMesh.")

-- Apply the MeshId and TextureId


charter["Building
Tools"].SyncAPI.ServerEndpoint:InvokeServer("SyncMesh", {
[1] = { ["Part"] = mesh.Parent, ["MeshId"] = meshid,
["TextureId"] = textureid }
})
print("Mesh synced: MeshId = ", meshid, " TextureId = ",
textureid)
end
end
end)
if not success then
warn("Error in recreatePart: ", err)
end
end
end

-- Main Script Logic


local build = BuildManager.LoadBuildModel(assetId)
BuildManager.PrepareBuild(build, parent)

local fakebuild = BuildManager.CreateFakeBuild(build, charter)

local pressed = false


mouse.Button1Down:Connect(function()
pressed = true
end)

spawn(function()
repeat
task.wait(0.25)
BuildManager.MoveFakeBuild(fakebuild, mouse)
until pressed
end)

mouse.Button1Down:wait()

pcall(function()
fakebuild:Destroy()
build.Parent = Workspace
build:MoveTo(mouse.Hit.p)
end)
-- Progress Tracking
local parts = build:GetChildren()
local totalParts = #parts
local placedParts = 0

print(string.format("Starting placement of %d parts...", totalParts))

for _, part in pairs(parts) do


task.wait(0.25)

-- Attempt to recreate the part


local success, err = pcall(function()
PartBuilder.RecreatePart(part, charter, parent)
end)

if success then
placedParts = placedParts + 1
-- Console Output: Show Progress
print(string.format("Placed %d/%d parts (%.2f%% complete)", placedParts,
totalParts, (placedParts / totalParts) * 100))
else
warn("Error processing part:", err)
end
end

print("Placement complete!")

--it auto picks your plot path idk dont ask why i added it its important or sm

local parts = build:GetChildren()

for i,v in pairs(parts) do

task.wait(0.25)

remakepart(v)

end

You might also like