Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make it so they have to click multiple times to remove?

So, I have this click on remove script, where when someone clicks the block it makes its transparency 1, and non-collide able, well I want to make it so when, the players have to click the block MULTIPLE times, in order to make it transparency 1, and non-collide able. Here is the regular script:

function onClicked()
script.Parent:remove()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment

0

I would do:

1 answer

✓ 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 -- This will decide how much more transparent this turns per click, set to 1 or delete and replace perClick down below with 1 if you want it to be set to 1 on your first click.
    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() -- I use destroy, while remove works, I find it good practice to use such methods.
    	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.

This discussion is preserved as it was. New answers, comments, and votes are closed.