Hi. I am trying to make a gun shoot so the glass breaks.
In 1 shot the crack decal transparency is 0.5, in 2 shots the decal transparency is 0 and in 3 shots it makes the part unanchored.
The only problem is I need to touch it and shoot it to make it work.
This is the explorer:
This is the script:
local hits = 0
script.Parent.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
if hit.Name == "Bullet" then
hits = hits +1
if hits >= 1 then
script.Parent.Decal.Transparency = .5
end
if hits >= 2 then
script.Parent.Decal.Transparency = 0
end
if hits >= 3 then
hits = 3
script.Parent.Anchored = false
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 50000
explosion.BlastRadius = 3
explosion.DestroyJointRadiusPercent = 0
explosion.Position = CFrame.new(script.Parent.CFrame.X, script.Parent.CFrame.Y, script.Parent.CFrame.Z)
explosion.ExplosionType = Enum.ExplosionType.CratersAndDebris
wait(10)
script.Parent:Destroy()
end
end
end
end)
Can someone help me so I dont need to touch the glass while shooting at it to break it. I want it to break when you shot but without you needing to touch it.
