Answered by
4 years ago Edited 4 years ago
I tested this and it's working but, I'm assuming you are trying to make it slightly invisible and uncollideable then after a period of time it goes back to normal right?
Then you need to add debounce! To prevent multiple action while one is running.
The reason it doesn't work as it supposed to do is because when you try to go through the door, your character will be touching the part and runs your touched event.
04 | script.Parent.Touched:Connect( function (hit) |
07 | if hit and hit.Parent and hit.Parent:FindFirstChild( "Humanoid" ) then |
08 | script.Parent.Transparency = 0 |
10 | script.Parent.Transparency = 0.3 |
12 | script.Parent.Transparency = 0.7 |
13 | script.Parent.CanCollide = false |
16 | script.Parent.Transparency = 0.7 |
18 | script.Parent.Transparency = 0.3 |
20 | script.Parent.Transparency = 0 |
21 | script.Parent.CanCollide = true |
FYI:
You can use for i loop to change transparency of your part, etc for a smooth effect. Example:
04 | script.Parent.Touched:Connect( function (hit) |
07 | if hit and hit.Parent and hit.Parent:FindFirstChild( "Humanoid" ) then |
09 | script.Parent.Transparency = i * 0.1 |
12 | script.Parent.CanCollide = false |
17 | script.Parent.Transparency = 1 - i * 0.1 |
20 | script.Parent.CanCollide = true |