Hello,
I’m currently using an ‘older’ brick fragmentation script (I have very minimal scripting knowledge, I am trying to learn.)
This script actually works perfectly, for the most part, on what I’m trying to accomplish. Although, I have one problem… When the brick actually does fragment in a game test it changes the material to a default plastic. I’m trying to get it to where it keeps the material, i.e brick/wood planks/etc.
Would anyone happen to know how I could accomplish this?
- From what I think I’m understanding correctly, this part of the script is the part that determines what happens to the brick when it fragments:
Summary
function fragmentate(cframe,size,color,explosion_position,explosion_blastradius,backsurface,bottomsurface,frontsurface,leftsurface,rightsurface,topsurface,transparency,reflectance)
local xi = size.X >= minimumsize.X*(1+explosion_blastradius/16) and 2 or 1 --to reduce the lagg in large explosions we increase minimumsize based on the explosionradius...
local yi = size.Y >= minimumsize.Y*(1+explosion_blastradius/16) and 2 or 1
local zi = size.Z >= minimumsize.Z*(1+explosion_blastradius/16) and 2 or 1
if xi == 1 and yi == 1 and zi == 1 or (cframe.p-explosion_position).magnitude > size.magnitude/2 + explosion_blastradius then --don�t fragmentate parts, that are too small to fragmentate or too far away from the explosion
if xi == 1 and yi == 1 and zi == 1 then return end --optional
if #storage > 0 then
local p = storage[1]
p.BrickColor = color
p.Size = size
p.BackSurface = backsurface
p.BottomSurface = bottomsurface
p.FrontSurface = frontsurface
p.LeftSurface = leftsurface
p.RightSurface = rightsurface
p.TopSurface = topsurface
p.Transparency = transparency
p.CFrame = cframe
p.Reflectance = reflectance
table.remove(storage,1)
else
local p = Instance.new("Part",fragmentable)
p.BrickColor = color
p.Anchored = true
p.FormFactor = "Custom"
p.Size = size
p.BackSurface = backsurface
p.BottomSurface = bottomsurface
p.FrontSurface = frontsurface
p.LeftSurface = leftsurface
p.RightSurface = rightsurface
p.TopSurface = topsurface
p.Transparency = transparency
p.CFrame = cframe
p.Reflectance = reflectance
end