Hi everyone,
I have been working on this system that is sepost to show sertain parts when the player enters buildmode. This is mostly going great but when removing sertain parts (Parts facing North) it just doesn’t do anything .
Note:
The other parts do work, just the north faceing parts dont’t.
Video with the problem:
The green parts you see are 4 of these elements:
(The red elements in this picture are the elements that are the problem)
This is the script (function) that I wrote that should work, but doesn’t :
local function Update(Plots)
for _, Plot in pairs(Plots) do
for _, Part in pairs(Plot:FindFirstChild("Build"):GetChildren()) do
local SplitParts = string.split(Part.Name, "|")
local Number = SplitParts[2]:match("^%s*(.-)%s*$")
if Part.Name:find("Base") then
local RaySouth = game.Workspace:Raycast(Part.Position, Vector3.new(0, 0, -Radius))
local RayNorth = game.Workspace:Raycast(Part.Position, Vector3.new(0, 0, Radius))
local RayWest = game.Workspace:Raycast(Part.Position, Vector3.new(Radius, 0, 0))
local RayEast = game.Workspace:Raycast(Part.Position, Vector3.new(-Radius, 0, 0))
if RayNorth and RayNorth.Instance then
print(Part.Name.." --- found an part on direction North called --> "..RayNorth.Instance.Name)
for _, SelectionParts in pairs(Plot:FindFirstChild("BuildmodeParts"):GetChildren()) do
if SelectionParts.Name:find("SelectionParts | "..Number.." |") then
if SelectionParts:FindFirstChild("Wall3") then SelectionParts:FindFirstChild("Wall3"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Corner_Bit2") then SelectionParts:FindFirstChild("Roof_Corner_Bit2"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Corner_Bit3") then SelectionParts:FindFirstChild("Roof_Corner_Bit3"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Trim3") then SelectionParts:FindFirstChild("Roof_Trim3"):Destroy() end
end
end
else
-- Nothing yet
end
if RayEast and RayEast.Instance then
print(Part.Name.." --- found an part on direction East called --> "..RayEast.Instance.Name)
for _, SelectionParts in pairs(Plot:FindFirstChild("BuildmodeParts"):GetChildren()) do
if SelectionParts.Name:find("| "..Number.." |") then
if SelectionParts:FindFirstChild("Wall2") then SelectionParts:FindFirstChild("Wall2"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Corner_Bit1") then SelectionParts:FindFirstChild("Roof_Corner_Bit1"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Corner_Bit2") then SelectionParts:FindFirstChild("Roof_Corner_Bit2"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Trim2") then SelectionParts:FindFirstChild("Roof_Trim2"):Destroy() end
end
end
else
-- Nothing yet
end
if RaySouth and RaySouth.Instance then
print(Part.Name.." --- found an part on direction South called --> "..RaySouth.Instance.Name)
for _, SelectionParts in pairs(Plot:FindFirstChild("BuildmodeParts"):GetChildren()) do
if SelectionParts.Name:find("| "..Number.." |") then
if SelectionParts:FindFirstChild("Wall1") then SelectionParts:FindFirstChild("Wall1"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Corner_Bit1") then SelectionParts:FindFirstChild("Roof_Corner_Bit1"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Corner_Bit4") then SelectionParts:FindFirstChild("Roof_Corner_Bit4"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Trim1") then SelectionParts:FindFirstChild("Roof_Trim1"):Destroy() end
end
end
else
-- Nothing yet
end
if RayWest and RayWest.Instance then
print(Part.Name.." --- found an part on direction West called --> "..RayWest.Instance.Name)
for _, SelectionParts in pairs(Plot:FindFirstChild("BuildmodeParts"):GetChildren()) do
if SelectionParts.Name:find("| "..Number.." |") then
if SelectionParts:FindFirstChild("Wall4") then SelectionParts:FindFirstChild("Wall4"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Corner_Bit3") then SelectionParts:FindFirstChild("Roof_Corner_Bit3"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Corner_Bit4") then SelectionParts:FindFirstChild("Roof_Corner_Bit4"):Destroy() end
if SelectionParts:FindFirstChild("Roof_Trim4") then SelectionParts:FindFirstChild("Roof_Trim4"):Destroy() end
end
end
else
-- Nothing yet
end
end
end
end
end
(There are parts that say “Nothing yet”, these I need to fill in later)
If someone could figger out what is wrong I would very much appreciate it