of     1   

warboy4life
#18013086Saturday, December 19, 2009 3:04 AM GMT

This script splits large bricks into smaller bricks, then repeats on the smaller bricks until they get too small. Does anyone see a way I can improve this? Make it more efficient/less laggy? When I use this for my bomb, it lags so much. function Split(part) local Origin = part local X = Origin.Position.x local Y = Origin.Position.y local Z = Origin.Position.z local SizeX = Origin.Size.x/(Origin.Size.x/(Origin.Size.x/4) ) local SizeY = Origin.Size.y/(Origin.Size.y/(Origin.Size.y/4) ) local SizeZ = Origin.Size.z/(Origin.Size.z/(Origin.Size.z/4) ) if(SizeX*SizeY*SizeZ>=1)then local A = Instance.new("SpawnLocation") local B = Instance.new("SpawnLocation") local C = Instance.new("SpawnLocation") local D = Instance.new("SpawnLocation") local E = Instance.new("SpawnLocation") local F = Instance.new("SpawnLocation") local G = Instance.new("SpawnLocation") local H = Instance.new("SpawnLocation") function Copy(Fragment) Fragment.BrickColor = Origin.BrickColor Fragment.Material = Origin.Material Fragment.TopSurface = Origin.TopSurface Fragment.BottomSurface = Origin.BottomSurface Fragment.Anchored = Origin.Anchored Fragment.Locked = Origin.Locked Fragment.formFactor = Origin.formFactor if( ((Origin.Size/2).x%2) == 0 )and( ((Origin.Size/2).y%2) == 0 )and( ((Origin.Size/2).z%2) == 0 )then Fragment.Size = Origin.Size/2 Mesh = Instance.new("BlockMesh") Mesh.Parent = Fragment else Fragment.Size = Origin.Size/2 Mesh = Instance.new("BlockMesh") local x = 0 local y = 0 local z = 0 if ( ( ((Origin.Size/2)*10).x%2) == 1 )or( ((Origin.Size/2).x%2) == 1 ) then x = 0.5 end if ( ( ((Origin.Size/2)*10).y%2) == 1 )or( ((Origin.Size/2).y%2) == 1 ) then y = 0.5 end if ( ( ((Origin.Size/2)*10).z%2) == 1 )or( ((Origin.Size/2).z%2) == 1 ) then z = 0.5 end Mesh.Scale = ( (((Origin.Size/2)-Vector3.new(x, y, z))*10)/((((Origin.Size/2)-Vector3.new(x, y, z))*10)-(Vector3.new(x*2, y*2, z*2)*10)) )*1 Mesh.Parent = Fragment end Fragment.Parent = Origin.Parent end Copy(A) Copy(B) Copy(C) Copy(D) Copy(E) Copy(F) Copy(G) Copy(H) A.CFrame = CFrame.new(Vector3.new(X + SizeX, Y + SizeY, Z + SizeZ )) B.CFrame = CFrame.new(Vector3.new(X + SizeX, Y + SizeY, Z - SizeZ )) C.CFrame = CFrame.new(Vector3.new(X + SizeX, Y - SizeY, Z + SizeZ )) D.CFrame = CFrame.new(Vector3.new(X + SizeX, Y - SizeY, Z - SizeZ )) E.CFrame = CFrame.new(Vector3.new(X - SizeX, Y + SizeY, Z + SizeZ )) F.CFrame = CFrame.new(Vector3.new(X -SizeX, Y + SizeY, Z - SizeZ )) G.CFrame = CFrame.new(Vector3.new(X - SizeX, Y - SizeY, Z + SizeZ )) H.CFrame = CFrame.new(Vector3.new(X - SizeX, Y - SizeY, Z - SizeZ )) Split(A) Split(B) Split(C) Split(D) Split(E) Split(F) Split(G) Split(H) part:remove() end end Split(script.Parent)
DarkLight08
#18015406Saturday, December 19, 2009 3:43 AM GMT

So you are turning one big brick into multiple smaller bricks? That's a lag INCREASE. One brick, one set of calculations. Multiple bricks, multiple sets of calculations. It doesn't matter how big they are, the computer has to record the information of them such as the size, the colours, the position, the graphics and then it has to render it. Then it has to update its location relative to your player.
warboy4life
#18021707Saturday, December 19, 2009 5:55 AM GMT

Oh I see, it wasn't ever the script. I guess there isn't a way to rid most of the lag that is caused. Thanks though! At least now I won't be blaming the script for the lag.
DarkLight08
#18023984Saturday, December 19, 2009 7:44 AM GMT

Just try simplifying things. Instead of having a wall of seperate bricks like an actual brick wall, make it one big brick. It won't look bad.
warboy4life
#18024498Saturday, December 19, 2009 8:25 AM GMT

This splitting effect is so I can dig detailed tunnels through large bricks, without using too many bricks.

    of     1