Hello. im trying make script for acs that makes hole on some materials but,
i don’t know how to place attachments correctly
this is what i want to make
[Left - Processed]
[Right - Giving u an idea what to do]
Each colored part is representing an attachment position
this is my code
local bulletholesize = .125
local Hardness = {
[Enum.Material.WoodPlanks] = 0.2,
}
function Penetrate(Part:BasePart,CF:CFrame,Material:Enum.Material,BPn:number,Dist:number,Side:string)
if Hardness[Material] ~= nil then
local Penetrated = (BPn*Hardness[Material])/Dist-Part.Size[Side]
if Penetrated > 0 then
local PBtm,PTop,PLft,PRgt = Part:Clone(),Part:Clone(),Part:Clone(),Part:Clone()
local AB,AT,AL,AR = Instance.new("Attachment",Part),Instance.new("Attachment",Part),Instance.new("Attachment",Part),Instance.new("Attachment",Part)
local Middle = CF.Position+(CF.LookVector*-Part.Size[Side]/2)
local P = (Middle - Part.Position)
AB.WorldPosition = Vector3.new(0,P.Y+bulletholesize/2-Part.Size.Y/2,0)+Part.Position
AT.WorldPosition = Vector3.new(0,-P.Y-bulletholesize/2+Part.Size.Y/2,0)+Part.Position
AL.WorldPosition = Vector3.zero -- i just gave up here
AR.WorldPosition = Vector3.zero
end
end
end
So, are you trying to make it so there are holes in the part where those attachments are? I am not yet sure about what you are trying to accomplish. What is the image showing specifically? Also, what is acs, I have no idea sorry.
u can see wheres the attachment, there are the block. the attachments are working as position placeholder. (the cyan part in the half transparent block is the bullet hitting position)
local bullet = --a part representing the area to be removed
local hit = --path to the part being hit
local result: UnionOperation = hit:SubtractAsync({bullet})
result.UsePartColor = true
result.Name = hit.Name
--here you may want to clone textures/decals into the new instance
result.Parent = hit.Parent
hit:Destroy()
bullet:Destroy()
hit = result