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

Why isn't this debounce working?

I made a debounce that stops the Part from turning transparent if touched then once and then turn visible if it's done being touched,but it won't turn visible,why? Please show how you managed to fix it.

local Part = script.Parent
Touched = false
-----------------------------
    Part.Touched:connect(function(TouchedPart)
        Touched = true
        FoundHumanoid= TouchedPart.Parent:FindFirstChild("Humanoid")--Checks if it's a humanoid
		-----------------------------
                if not FoundHumanoid then
                    print("You're not a Character "..TouchedPart.Name.." !")
                else
				if not Touched then -- If not touched
				-----------------------------
					Part.TouchEnded:connect(function(TouchEnd)--If the touch has ended then do the following
				    print("I haven't been touched!")
				        Part.Transparency = 0
							Touched = false
					   end)
					-----------------------------
					else--If it's still touched then do the following
						 Part.Transparency = 0.5
                         print("I've been touched")
						Touched = false
										
				      end 
					end
				  end)

1 answer

✓ Accepted answer

I was here before but this should help ;)

local Part = script.Parent
Touched = false
-----------------------------
    Part.Touched:connect(function(TouchedPart)
        Touched = true
        FoundHumanoid= TouchedPart.Parent:FindFirstChild("Humanoid")--Checks if it's a humanoid
        -----------------------------
                if not FoundHumanoid then
                    print("You're not a Character "..TouchedPart.Name.." !")
                else
                -----------------------------
                         Part.Transparency = 0.5
                         print("I've been touched")
                        Touched = false

                    end
                  end)

                    Part.TouchEnded:connect(function(TouchEnd)--If the touch has ended then do the following
                    print("I haven't been touched!")
                        Part.Transparency = 0
                            Touched = false
                       end)

1 comment

0

I know this is really messy coding, But I didn't attempt to make it look good as he should be able to understand hehe

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