Disappearing block problem

  1. Hello!, i make a disappearing block script, that when players touch the part, it disappear

  2. The problem is when player spam jump button, block doesnt dissapear

  3. Heres the script

local block = script.Parent
local debounce= true

block.Touched:Connect(function(hit)
	local humanoid=hit.parent:FindFirstChildWhichIsA("Humanoid")
	if humanoid and debounce == true then
		debounce=false
		block.Transparency = 0.5
		wait(1)
		block.Transparency=0
		block.CanCollide=false
		wait(5)
		block.Transparency=0.5
		block.CanCollide=true
		debounce=true
	end
end)

Thanks for read! :grin:

2 Likes

you seemed to have misspelled Parent here. Make sure your code is spelled correctly and looks neat. I would also add spaces between the “=” for neater code. Is this only for when the player spams the jump button? Because the code seems fine to me if you make the Parent fix. (also make sure it is a (Server) Script not a LocalScript).

yes is only when player spams jump button, work great actually, just the problem the block
does not disappear instantly, and is not a local script.

well these waits are why your block doesn’t disappear instantly if that is what you are trying to figure out. If you mean it just won’t respond at all to when the player is spam jumping on the part that could just be the Touched event, but I don’t think that should be an issue since the player is touching it. Do you have any other scripts in your game that could be messing with the part? Like a TouchEnded event?

tha wait start after the player touch so cant be that, and no, theres no touchended

try using print() then to see if your Touched event is reacting to when a player spam jumps on the part. If it is that, you might need to mess with how fast the character can jump (I really don’t see this being a problem), but if it isn’t there must be something else messing with your part. Use print() inside and outside the if statement just to see what it does.