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)
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)
I think you need to put both Part.Transparency's as 0.5.