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

Help with TouchEnded event?

I was making a script where if a Character touches the part it will turn half transparent and then it will go back to normal if he leaves the part but it won't go back to normal,why?

local Part = script.Parent
local Touched = false--Debounce

    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.." !")
                    Touched = false
                else
                    if not Touched then
                        print("I haven't been touched!")
                        Part.Transparency = 1
                    else
                        Part.Transparency = 0.5
                         print("I've been touched")
						Touched = false
                end 
            end
    end)

1 comment

0

This script has been fixed

2 answers

✓ Accepted answer

TouchEnded does not work the last way you tried before the edit and now after you edited it doesn't check TouchEnded at all to fix this

Remove this

                    if not Touched then
                        print("I haven't been touched!")
                            Touched = false
                        Part.Transparency = 0
                    else

Add this

Part.TouchEnded:connect(function(Touchee) 
	print("I haven't been touched!")
        Touched = false
        Part.Transparency = 0
end)

2 comments

0

Sorry for the edit,I was trying to clean it up

0

That's fine just do the edits on your script as I said and you will be good ;)

I think you need to put both Part.Transparency's as 0.5.

4 comments

0

It does that in line 16

0

Well then try deleting the first part.

0

What first part?

0

Line 12-15.

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