✓ Accepted answer
This is very simple, make a local variable to the amount of clicks you want it to take, for example.
local clickAmount = 5
local perClick = 0.2
function onClicked()
clickAmount = clickAmount - 1
script.Parent.Transparency = script.Parent.Transparency + perClick,
if script.Parent.Transparency == 1 then
script.Parent.CanCollide = false
end
if clickAmount == 0 then
script.Parent:Destroy()
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
I apologize however, I was unsure if you wanted the part to work so it doesn't destroy/remove and just becomes transparent, so I added multiple fairly simple blocks of code into this 1 function for you, to make sure I didn't miss any details.
So as the code states, clickAmount is equal to the amount of clicks it takes before the part is completely destroyed -- DELETE THIS IF YOU WANT THE PART TO REMAIN IN THE SERVER
Now, perClick will set the transparency to the current transparency and add it by 0.2, and if the transparency = 1, CanCollide = false DELETE THAT IF YOU WANT CANCOLLIDE TO BE FALSE ON THE FIRST CLICK
and lastly, if clickAmount = 0 then Destroy, once again, if you want it to always remain in workspace, delete that code.
I was unsure how to go about the answer, so I added 3 of the potential things you may want into one function, edit it as you see fit.
1 comment
I would do: