I have a door type wall set to detect if an npc is in the current location, when the server first starts the door is open, but when I change the value to something else through console the door wont close. How do I fix this?
my code:
1 | if game.Workspace.NPCs.Collector.CurrentWell.Value = = "Beach" then |
2 | wait( 20 ) |
3 | script.Parent.Transparency = 1 |
4 | script.Parent.CanCollide = false |
5 | else |
6 | script.Parent.Transparency = 0 |
7 | script.Parent.CanCollide = true |
8 | end |
The solution is the changed function.
01 | well = game.Workspace.NPCs.Collector.CurrentWell |
02 | well.Changed:Connect( function () |
03 | if well.Value = = "Beach" then |
04 | script.Parent.Transparency = 1 |
05 | script.Parent.CanCollide = false |
06 | else |
07 | script.Parent.Transparency = 0 |
08 | script.Parent.CanCollide = true |
09 | end |
10 | end ) |