|
| 08 Apr 2015 09:10 PM |
Hi. I made a Key Script that's supposed to unAnchor a Door connected with it inside the Script's Code. However, If you touch anything with the key it will Unanchor the part you touch is connected to.
Any possible fixes?
Full Script :
script.Parent.Handle.Touched:connect(function(part) local Door = workspace.Door local Activator = Door.Knob if Activator and Activator.Parent then if Activator.Parent.Name == "Door" and Activator.Name == "Knob" then local doorParts = part.Parent:GetChildren() for i=1, #doorParts do if doorParts[i].Anchored == true then doorParts[i].Anchored = false Door.SFUnlock:Play() end end end script.Parent:Destroy() end end)
|
|
|
| Report Abuse |
|
|
|
| 08 Apr 2015 10:13 PM |
| Maybe I should make the top half a seperate function. |
|
|
| Report Abuse |
|
|
iHin
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 407 |
|
|
| 08 Apr 2015 10:17 PM |
1. "workspace" is deprecated: consider changing.
2. To check if the Activator and Parent exist use "findFirstChild()"
3. Be sure to put a "wait()" with your for function. |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Apr 2015 10:29 PM |
| Can you provide an Example of how I would insert those recommendations into the Script Code? |
|
|
| Report Abuse |
|
|