Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with TouchEnded event?

Asked by 9 years ago

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)

0
This script has been fixed NovusTheory 133 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

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)
0
Sorry for the edit,I was trying to clean it up kevinnight45 550 — 9y
0
That's fine just do the edits on your script as I said and you will be good ;) NovusTheory 133 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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

0
It does that in line 16 kevinnight45 550 — 9y
0
Well then try deleting the first part. InfernoChaosInfinity 2 — 9y
0
What first part? kevinnight45 550 — 9y
0
Line 12-15. InfernoChaosInfinity 2 — 9y

Answer this question