I'm new to scripting and I'm experimenting with this new thing I learned but it won't work. The script is below. Please fix it and explain what I did wrong. The point of this script is to slowly make the brick transparency until it disappears and then remove it.
function touch script.Parent.Transparency = 0.2 wait(0.5) script.Parent.Transparency = 0.5 wait(0.5) script.Parent.Transparency = 0.7 wait(0.5) script.Parent.Transparency = 1 wait(0.5) script.Parent:remove() end script.Parent.Touched:connect(touch) end
Thank-you.
There are multiple problems here.
First off, touch needs another item behind it. No, not just touch. You need to use touch() or touch(hit).
Second, remove() is depreciated. Use Destroy().
Third, why do the code this way? Much easier to use a for loop instead to save space.
Fourth, no need of the end at the end. end defines the end of some sort of function.
Here's the refinished script.
function touch() script.Parent.Transparency = 0.2 for i=1,3 do script.Parent.Transparency=script.Parent.Transparency+0.3 wait(0.5) end script.Parent:Destroy() end script.Parent.Touched:connect(touch)
If this helped, make sure to hit the accept button on the right. Cya!