Skip to content

Instantly share code, notes, and snippets.

@Anaminus
Last active May 28, 2021 14:07
Show Gist options
  • Select an option

  • Save Anaminus/37f005972c1aa42c791fb21e9ce67610 to your computer and use it in GitHub Desktop.

Select an option

Save Anaminus/37f005972c1aa42c791fb21e9ce67610 to your computer and use it in GitHub Desktop.
Some men just want to watch the wood burn.
-- LocalScript; Parent = ReplicatedFirst
-- Adornments not supported.
local WoodReviewerUserIDs = {
[102925343] = true,
}
if not WoodReviewerUserIDs[game:GetService("Players").LocalPlayer.UserId] then
return
end
local rotationMap = CFrame.Angles(math.pi/2,math.pi/2,0)
local sizeMap = {x = "y", y = "z", z = "x"}
local surfaceMap = {
Back = "Top";
Right = "Back";
Top = "Right";
Bottom = "Left";
Left = "Front";
Front = "Bottom";
}
local faceProperty = {
FaceInstance = {"Face"},
Feature = {"FaceId"},
SpotLight = {"Face"},
SurfaceLight = {"Face"},
SurfaceSelection = {"TargetSurface"},
ParticleEmitter = {"EmissionDirection"},
}
local function reorientSurface(wood, name)
local values = {}
for old, new in pairs(surfaceMap) do
values[new] = wood[old..name]
end
for new, value in pairs(values) do
wood[new..name] = value
end
end
local function reorientEquipment(wood)
for _, child in pairs(wood:GetChildren()) do
local continue = false
for class, props in pairs(faceProperty) do
if child:IsA(class) then
for _, prop in pairs(props) do
local surface = child[prop].Name
child[prop] = Enum.NormalId[surfaceMap[surface]]
end
continue = true
end
if continue then break end
end
end
end
local function reorientWood(wood)
local size = wood.Size
local cframe = wood.CFrame
reorientSurface(wood, "Surface")
reorientSurface(wood, "SurfaceInput")
reorientSurface(wood, "ParamA")
reorientSurface(wood, "ParamB")
reorientEquipment(wood)
wood.Size = Vector3.new(size[sizeMap.x],size[sizeMap.y],size[sizeMap.z])
wood.CFrame = cframe*rotationMap
end
local function checkWood(object)
if object:IsA("Part") and object.Material.Name:match("Wood") then
reorientWood(object)
end
end
workspace.DescendantAdded:connect(checkWood)
local function recurse(object)
checkWood(object)
for _, child in pairs(object:GetChildren()) do
recurse(child)
end
end
recurse(workspace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment