Can you write the script that you meant
heres what breaks it
local Module = require(script:WaitForChild("PartFractureModule"))
if hit.Material == Enum.Material.Glass then
local attach = Instance.new("Attachment")
attach.Parent = hit
attach.Name = "BreakingPoint"
attach.Visible = true
local BreakingPoint = hit:FindFirstChild("BreakingPoint")
if BreakingPoint and BreakingPoint:IsA("Attachment") then
BreakingPoint.WorldPosition = position
BreakingPoint.Position = Vector3.new(BreakingPoint.Position.X, BreakingPoint.Position.Y, BreakingPoint.Position.Z)
Module.FracturePart(hit)
end
end
Keep in mind that this is from raycasting
Sure, you can use the BasePart.Touched event for that. That will only work though if youâre not setting the ballets position with CFrames.
If youâre making your own gun, Iâd recommend connecting the event you use to control hits to a checker to see if the hit was a suitable glass model/part. You can then use the OS module I posted above and the position of the bullet (and some math) to find the fracture point and fracture the glass.
Would this work?
local GlassPiece = script.Parent
local Wedges = GlassPiece.Parent:GetChildren(GlassWedge)
local Humanoid = script.Parent.Humanoid
Humanoid.Died:Connect(function()
GlassPiece:Destroy()
for i, v in pairs(Wedges) do
v.Transparency = 0
v.CanCollide = true
v.Anchored = false
end
end)
I remember someone just talked about of the humanoid script before ,
Can you tell the algorithm of this script?
Yeah that looks good. Remember to organize it like this:
model
hittable part
humanoid
âŠ
So that itâs similar to a normal character/rig.
This creates a attachment that is parented to hit then i just took the code they gave here
ı am wondering about the difference from the character/rig
A character is a playerâs rig. A rig is a model with a humanoid and base parts inside of it, usually with an animator and constraints.
Edit:
A character is a rig, though rig isnât super specific.
If we going to make this system in to the gun tool , then
Do we have to add this script in to the gun model?
Or in to the bullet model
Which ı just talked about of it before
And whats happen if we put this script in to both of them?
This script would go into the glass. Youâd also need to format it correctly.
You could always just raycast to the glass pane from the barrel or (if using a crosshair that isnât fixed) you could use CFrame:ToWorldSpace and raycast to there. Then youâd just fire an event when the glass connects with the raycast, you dont need a physical Touched part.
Well can you tell the algorithm of the physical touched part , ı mean can you tell me the logic of it?
And what is the most sensible way to make breaking glass.
Touched would just detect if your bullet that youâre presumably CFraming touched the glass, then youâd fire the event. The module mentioned above would work great for fragmenting it. However, Touched is not super performant, so Iâd recommend firing a raycast from the gun outwards (which youâre probably already doing since it is a gun), detect if the part that it intersects is glass, and then you can fire your fragmentation script.