|
| 27 Jul 2015 08:08 PM |
function KillAnchored(hit) if hit:FindFirstChild("Safe") then elseif hit:IsA("Part") then hit.Anchored = false end end
script.Parent.Touched:connect(KillAnchored)
This script is suppose to unanchored parts on touch, however it doesn't work. This time the script isn't disabled.
Also, if this part touched another part in a group would it not work? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 08:21 PM |
Test if it is touched then in the function type in "script.Parent.Anchored = false" Thanks for listening it should go something like:
function onTouch(part) script.Parent.Anchored = false end script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
cgjnm
|
  |
| Joined: 22 Dec 2011 |
| Total Posts: 2347 |
|
|
| 27 Jul 2015 08:23 PM |
if hit:FindFirstChild("Safe") then elseif hit:IsA("Part") then hit.Anchored = false end
--That is unnecessary,
if not hit:FindFirstChild'Safe'and hit:IsA'Part'then hit.Anchored = false end |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 08:39 PM |
Thanks for the replies.
@cgn you can write :FindFirstChild with '' instead of ("")?
also, it didn't seem to work for some reason, although it's probably how I structured my 'safe' thing that messed it up. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 08:59 PM |
| Even with the replies, this script doesn't work. |
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
|
| 27 Jul 2015 09:13 PM |
First of all, where is this script located? Also, do you want to unanchor ANY part that you touch? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 10:13 PM |
| This script is located inside a union, and no, there is a number value inside parts I don't want to be unachored called "Safe". |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Jul 2015 10:15 PM |
local p = script.Parent
p.Touched:connect(function(hit) local parent= hit.Parent if parent and not parent:FindFirstChild("Safe") then hit.Anchored = false end end) |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 10:22 PM |
@insta thanks for replying, but the parts were still anchored after being touched by the part.
Here's a bit more information, the parts that are being touched are in a model titled "Map1". There's one part in "Map1" with the safe numbervalue in it, that part is called "BasePlate". |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Jul 2015 10:27 PM |
| wait, is the safe value inside of the brick? |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Jul 2015 10:28 PM |
if so, simply do this:
local p = script.Parent
p.Touched:connect(function(hit) if hit.Parent and not hit:FindFirstChild("Safe") then hit.Anchored = false end end) |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 10:37 PM |
| This time it didn't work either. However, I left out one part. The part is being C-Framed when this script is ran, so maybe that's the issue? |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Jul 2015 10:41 PM |
.. dear lordy
you see, when you adjust the cframe of an object, and it happens to collide with another, .Touched isn't fired
so yes, it would have helped if you told us that a while ago |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 10:43 PM |
| Sorry, I'm not the most technical scripter. Yes, you're right I should have told you that from beginning. Is there a way I could make it detect, however? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 10:46 PM |
| @insta you're post count tho lol |
|
|
| Report Abuse |
|
|