generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Ontouch Unanchor

Previous Thread :: Next Thread 
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
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
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
23 May 2013 10:06 PM
bump??????????
Report Abuse
Phantom0922 is not online. Phantom0922
Joined: 15 May 2010
Total Posts: 151
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 is not online. 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
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
24 May 2013 08:56 PM
just put in a block, and it will unanchor all parts in the model, correct?
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
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
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
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
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
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
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
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
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
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
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
24 May 2013 09:38 PM
I just tested it. And it worked >-<
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
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
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
24 May 2013 09:45 PM
If you really want to.
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
24 May 2013 09:49 PM
I see no other way.

http://www.roblox.com/Broken-ontouched-unanchoring-item?id=116805858
Report Abuse
Ekkoh is not online. 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
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
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
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
24 May 2013 10:13 PM
When I touch the block, nothing happens.
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
24 May 2013 10:16 PM
Yus, it works now!
Report Abuse
godzillabob5 is not online. godzillabob5
Joined: 14 Jul 2009
Total Posts: 1047
24 May 2013 10:16 PM
Thank you, screw
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image