I need to make the decal go transparent with the decal. And also add a glass smashing noise.
01 | local debounce = false |
02 | script.Parent.Anchored = true -- Anchores brick |
03 | script.Parent.ClickDetector.MouseClick:Connect( function () |
04 | if debounce = = false then |
05 | debounce = true |
06 | script.Parent.Transparency = 1 -- Makes Block Invisible |
07 | script.Parent.CanCollide = false -- Lets Player Walk Through Block |
08 |
09 | debounce = false |
10 | end |
11 | end ) |
I do not know Lua, I copypasted this code. Give me what I need to add. I'll try to learn it.
To add a "glass smashing noise" you will need to first, find the id of the audio (roblox), then create a script that when your ClickDetector
event is fired, it will insert a sound instance into that part with the valid id.
To make a decal transparent it is the same as any BasePart
, simply state decal.Transparency = 1
Here is your (semi)completed code:
01 | local id = 69 ; -- // Number value |
02 | local debounce = false |
03 | script.Parent.Anchored = true -- Anchores brick |
04 | script.Parent.ClickDetector.MouseClick:Connect( function () |
05 | if debounce = = false then |
06 | local s = Instance.new( "Sound" ); |
07 | s.Parent = script.Parent; |
08 | s.SoundId = "rbxassetid://" .. id; |
09 | s:Play(); |
10 | debounce = true |
11 | script.Parent.Transparency = 1 -- Makes Block Invisible |
12 | script.Parent.Decal.Transparency = 1 ; -- // Change to your decals hierarchy position |
13 | script.Parent.CanCollide = false -- Lets Player Walk Through Block |
14 | debounce = false |
15 | end |
16 | end ) |
This will make the decal invisible and it will play sound when it smashes.
01 | local SmashSfx = Instance.new( "Sound" ) |
02 | SmashSfx.Parent = script.Parent |
03 | SmashSfx.SoundId = "rbxassetid://" -- Put the id here |
04 | SmashSfx.Volume = 1 -- Change the volume of the Audio/Sound |
05 | SmashSfx.Looped = false -- Keep this false |
06 | SmashSfx.Archivable = false -- Also keep this false |
07 |
08 |
09 | local debounce = false |
10 | script.Parent.Anchored = true -- Anchores brick |
11 | script.Parent.ClickDetector.MouseClick:Connect( function () |
12 | if debounce = = false then |
13 | debounce = true |
14 | script.Parent.Transparency = 1 -- Makes Block Invisible |
15 | script.Parent.CanCollide = false -- Lets Player Walk Through Block |