|
| 17 May 2013 10:09 PM |
I borrowed this script of another post, since noone is replying to it.
I needed a script so that when you touched a certain block, all blocks in that model would become unanchored.
I have put the script below into a "Part" in the model, and touched it to no avail.
Do I need a touchintrest or do I need to do something different?
function onTouched() P = script.Parent.Parent:GetChildren() for i = 1, #P do if P[i].ClassName == "Part" then P[i].Anchored = false end end
script.Parent.Touched:connect(onTouched)
--Thanks to KillerKyle |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 May 2013 10:34 PM |
Try this
function onTouched() P = script.Parent.Parent:GetChildren() for i,v in pairs(P) do if P[i].ClassName == "Part" then P[i].Anchored = false end end end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
spearman2
|
  |
| Joined: 28 May 2010 |
| Total Posts: 2938 |
|
|
| 23 May 2013 10:36 PM |
function onTouched() P = script.Parent.Parent:GetChildren() for i = 1, #P do if P[i].ClassName == "Part" then P[i].Anchored = false end --You forgot and end here :P end end
script.Parent.Touched:connect(onTouched)
There, that should work. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 08:56 PM |
| just put in a block, and it will unanchor all parts in the model, correct? |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 09:05 PM |
^ I did this, but It isn't working.
I couldn't find anything wrong with the script however. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 09:07 PM |
| The function in those scripts are ran when you touch the part that's both in the model and has the script in it. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 09:15 PM |
Thats what I was thinking happened, however when I put it into a part, it does not unanchor anything when touched.
Is this some weird thing that only works when Im "Playing" and not building |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 09:18 PM |
print("Hi") P = script.Parent.Parent:GetChildren() function onTouched(derp) if not derp.Parent:FindFirstChild("Humanoid") then return end for i,v in pairs(P) do if v.ClassName == "Part" then v.Anchored = false end end end script.Parent.Touched:connect(onTouched) --doesn't hurt to add all of that |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 09:33 PM |
I must be doing something wrong
I made all the bricks under the model named "Part"
I tryed touching the block with the script in it. No effect.
I Change the Scripts name to "script" No effect.
What am I missing?? |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 09:38 PM |
| I just tested it. And it worked >-< |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 09:43 PM |
Problem with my studio?
I hate to stoop this low, but make it in a working model?
Or I could make a model and send it to you?
Im soo confused. |
|
|
| Report Abuse |
|
|
| |
|
|
| 24 May 2013 09:49 PM |
I see no other way.
http://www.roblox.com/Broken-ontouched-unanchoring-item?id=116805858 |
|
|
| Report Abuse |
|
|
Ekkoh
|
  |
| Joined: 22 Oct 2012 |
| Total Posts: 524 |
|
|
| 24 May 2013 10:05 PM |
| Tested that exact model, worked fine. What's wrong with yours? |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 10:13 PM |
P = script.Parent.Parent:GetChildren() function onTouched(derp) print("Start") if derp.Parent:FindFirstChild("Humanoid") then print("yeah!") for i,v in pairs(P) do if v.ClassName == "Part" then v.Anchored = false end end end end script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 10:13 PM |
| When I touch the block, nothing happens. |
|
|
| Report Abuse |
|
|
| |
|
| |
|