Hello!, i make a disappearing block script, that when players touch the part, it disappear
The problem is when player spam jump button, block doesnt dissapear
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)
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).
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?
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.