FE Gun Kit breakable planks on base of shattering glass

So i want to make breakable planks. I want them to break by shooting them few times, and then breaking into pieces like normal shattering glass does, but also emitting different sound.

I have tried searching but found no information about what i need, and also tried to look at codes of FE gun kit but i dont know how to edit it correctly to implement that.

Im using that https://create.roblox.com/marketplace/asset/9477229933/AMMO-FE-Gun-kit-Viewmodel-2
I hope somebody can figure it out and help me.

Make the planks have health attributes, and edit your damage code so that it can also damage planks and destroy them if their health reaches 0.

Your hit detection should also account for detecting planks.

Oh, actually i didnt think of that, now im thinking of it and undertanding that its so simple. lol

Just rename it to _glass and edit the effects in SimulateBulletScript, that’s what I did to show a message when player shoots a plane.

But how do i detect material in SimulateBulletScript when bullet hits plank? And i want planks have some kind of hp so i need to shoot them few times?

make a numbervalue inside the plank named “Health” with the value being its health.

ShatterGlass.OnServerEvent:Connect(function(Player, Hit:BasePart?, Pos, Dir)
	if Hit then
		if Hit.Name == "_glass" then --It can be _plank but that would require editing every gun client script.
			if Hit.Health.Value > 0 and Hit.Transparency == 1 then -- YAY
				Hit.Healh.Value -= 15 -- damage. -- base health is 100. : )
				local Sound:Sound? = Instance.new("Sound") -- SFX Hit.
				Sound.RollOffMaxDistance = 70
				Sound.Volume = 0.7
				Sound.SoundId = "rbxassetid://4004052860"
				Sound.Parent = Hit
				Sound:Play()
				game:GetService("Debris"):AddItem(Sound, Sound.TimeLength - 0.1)
			else -- gone? 
				local Sound:Sound? = Instance.new("Sound") -- SFX Hit.
				Sound.RollOffMaxDistance = 70
				Sound.Volume = 0.7
				Sound.SoundId = "rbxassetid://158712406"
				Sound.Parent = Hit
				Sound:Play()
				game:GetService("Debris"):AddItem(Sound, Sound.TimeLength - 0.1)
			---	Hit.Transparency = 1 -- nvm the glass shatter does it 
				task.delay(2,function()
					Hit:Destroy()
					--Hit.Transparency = 0 -- or if you awnna make it respawn : )
					--Hit.Health.Value = 100 -- delete the comments if you wanna do the second option.
				end)
				GlassShattering:Shatter(Hit, Pos, Dir + Vector3.new(math.random(-25, 25), math.random(-25, 25), math.random(-25, 25)))
			end
		end
	end
end)

So uhh, where do i put this code actually?

In SimulateBulletScript, replace the ShatterGlass event with the one I posted. It should be here.

Ohhh so i can now detect maximum health of _glass object to set different sounds on break, am i right? Or should i add extra code strings to separate inside of function to make it work properly with different sounds? (i know i will need to get new “Maxhealth” numbervalue to it, no need to tell, and i will use it for extra stuff also, such as repairing structures later in development, thats why i will call it Maxhealth, not material or smth)

Yes the snippet does that for you, if plank health is above 0 then damage it for 15, if not shatter it then destroy it after 2 seconds, you can respawn it too if you wanna.
As for Material you can just use.

ShatterGlass.OnServerEvent:Connect(function(Player, Hit:BasePart?, Pos, Dir)
	if Hit then
		if Hit.Name == "_glass" then --It can be _plank but that would require editing every gun client script.
			if Hit.Material == Enum.Material.WoodPlanks then -- ?
				if Hit.Health.Value > 0 and Hit.Transparency == 1 then -- YAY
					Hit.Healh.Value -= 15 -- damage. -- base health is 100. : )
					local Sound:Sound? = Instance.new("Sound") -- SFX Hit.
					Sound.RollOffMaxDistance = 70
					Sound.Volume = 0.7
					Sound.SoundId = "rbxassetid://4004052860"
					Sound.Parent = Hit
					Sound:Play()
					game:GetService("Debris"):AddItem(Sound, Sound.TimeLength - 0.1)
				else -- gone? 
					local Sound:Sound? = Instance.new("Sound") -- SFX Hit.
					Sound.RollOffMaxDistance = 70
					Sound.Volume = 0.7
					Sound.SoundId = "rbxassetid://158712406"
					Sound.Parent = Hit
					Sound:Play()
					game:GetService("Debris"):AddItem(Sound, Sound.TimeLength - 0.1)
					---	Hit.Transparency = 1 -- nvm the glass shatter does it 
					task.delay(2,function()
						Hit:Destroy()
						--Hit.Transparency = 0 -- or if you awnna make it respawn : )
						--Hit.Health.Value = 100 -- delete the comments if you wanna do the second option.
					end)
					GlassShattering:Shatter(Hit, Pos, Dir + Vector3.new(math.random(-25, 25), math.random(-25, 25), math.random(-25, 25)))
				end
			end
		end
	end
end)

_glass objects stopped to break after i changed script to new with variations of sound.

What do you mean stopped to break? They’ll get destroyed after they shatter, if you want them to respawn there is an option.

When i shoot them few times which must be enough to shatter, even glass which is set to 15 health, they do not shatter, bullets go thru the _glass objects.

ShatterGlass.OnServerEvent:Connect(function(Player, Hit:BasePart?, Pos, Dir)
	if Hit then
		if Hit.Name == "_glass" then --It can be _plank but that would require editing every gun client script.
			if Hit.Material == Enum.Material.WoodPlanks then -- ?
				if Hit.Health.Value > 0 and Hit.Transparency ~= 1 then -- YAY
					Hit.Healh.Value -= 15 -- damage. -- base health is 100. : )
					local Sound:Sound? = Instance.new("Sound") -- SFX Hit.
					Sound.RollOffMaxDistance = 70
					Sound.Volume = 0.7
					Sound.SoundId = "rbxassetid://4004052860"
					Sound.Parent = Hit
					Sound:Play()
					game:GetService("Debris"):AddItem(Sound, Sound.TimeLength - 0.1)
				else -- gone? 
					local Sound:Sound? = Instance.new("Sound") -- SFX Hit.
					Sound.RollOffMaxDistance = 70
					Sound.Volume = 0.7
					Sound.SoundId = "rbxassetid://158712406"
					Sound.Parent = Hit
					Sound:Play()
					game:GetService("Debris"):AddItem(Sound, Sound.TimeLength - 0.1)
					---	Hit.Transparency = 1 -- nvm the glass shatter does it 
					task.delay(2,function()
						Hit:Destroy()
						--Hit.Transparency = 0 -- or if you awnna make it respawn : )
						--Hit.Health.Value = 100 -- delete the comments if you wanna do the second option.
					end)
					GlassShattering:Shatter(Hit, Pos, Dir + Vector3.new(math.random(-25, 25), math.random(-25, 25), math.random(-25, 25)))
				end
			end
		end
	end
end)

Try this i guess.

Still the same issue for no reason. I dont even get any output messages of any issues.

I just edited it again can you try it?

Last issue now im experiencing that it doesnt actually depend on health, just instantly breaking after getting shot.

It appears I made a mistake.

ShatterGlass.OnServerEvent:Connect(function(Player, Hit, Pos, Dir)
	ShatterGlass.OnServerEvent:Connect(function(Player, Hit:BasePart?, Pos, Dir)
		if Hit then
			if Hit.Name == "_glass" then --It can be _plank but that would require editing every gun client script.
				if Hit.Material == Enum.Material.WoodPlanks then -- ?
					if Hit.Health.Value > 0 and Hit.Transparency ~= 1 then -- YAY
						Hit.Health.Value -= 15 -- damage. -- base health is 100. : )
						local Sound:Sound? = Instance.new("Sound") -- SFX Hit.
						Sound.RollOffMaxDistance = 70
						Sound.Volume = 0.7
						Sound.SoundId = "rbxassetid://4004052860"
						Sound.Parent = Hit
						Sound:Play()
						game:GetService("Debris"):AddItem(Sound, Sound.TimeLength - 0.1)
					elseif Hit.Health.Value <= 0 then -- gone?
						local Sound:Sound? = Instance.new("Sound") -- SFX Hit.
						Sound.RollOffMaxDistance = 70
						Sound.Volume = 0.7
						Sound.SoundId = "rbxassetid://158712406"
						Sound.Parent = Hit
						Sound:Play()
						game:GetService("Debris"):AddItem(Sound, Sound.TimeLength - 0.1)
						---	Hit.Transparency = 1 -- nvm the glass shatter does it 
						task.delay(2,function()
							Hit:Destroy()
							--Hit.Transparency = 0 -- or if you awnna make it respawn : )
							--Hit.Health.Value = 100 -- delete the comments if you wanna do the second option.
						end)
						GlassShattering:Shatter(Hit, Pos, Dir + Vector3.new(math.random(-25, 25), math.random(-25, 25), math.random(-25, 25)))
					end
				end
			end
		end
	end)
end)

I tested it and it works fine.

Now again doesnt break, i spent all mags on glass and some more mags from ammo box on planks, both didnt break.

Huh?? I literally tested it and it broke for me? Are you sure you have a numbervalue named Health in your _glass?