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: I need help with the on touched function.

Previous Thread :: Next Thread 
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
31 Aug 2011 11:21 PM
I'm trying to get the script to make it's parent (the brick) unanchore everything it touches, but I don't want it to unanchor it if it's locked, because if it unanchores locked objects the baseplate will fall. So far I have changed the script atleast 10 different times and it won't work! I can't find any help about it in the wiki or anything. =[

I'm really having trouble with these on touched functions!
Report Abuse
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
31 Aug 2011 11:30 PM
I pretty much want it to look like:


if script.Parent=unlocked

function on touched
unanchor, or somthing like that? gaaah I'm so confused! :0
Report Abuse
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
31 Aug 2011 11:47 PM
I can't even get this to work!

function onTouched()
script.Parent.BrickColor = BrickColor.Random()
end
Report Abuse
getkoed is not online. getkoed
Joined: 18 Feb 2010
Total Posts: 2298
31 Aug 2011 11:53 PM
script.Parent.Touched:connect(function()
script.Parent.BrickColor = BrickColor.new(math.random)
end)

I didn't test it, I think it works :3
Report Abuse
getkoed is not online. getkoed
Joined: 18 Feb 2010
Total Posts: 2298
31 Aug 2011 11:54 PM
Also, don't forget to TAG your functions, so don't only stop the function with end.

function onTouch()
FUNCTION HERE
end

script.Parent.Touched:connect(onTouch)
Report Abuse
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
31 Aug 2011 11:57 PM
Thank you! I'll try it out!
Report Abuse
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
31 Aug 2011 11:58 PM
Okay this is what i have sofar and it's not working

function onTouched(part)
if part.Locked == false then
part:Anchored == false()
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
01 Sep 2011 12:06 AM
This is a problem I saw:

part:Anchored == false()


There are multiple things wrong with that line. First of all, it should be:
part.Anchored = false

When accessing values like anchored, etc. etc. you still use a period.
When SETTING values, you use 1 equal sign, not 2.
And its "false", not "false()"

Report Abuse
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
01 Sep 2011 12:12 AM
Oh thanks! I looked in the output and it said somthing was wrong on line 3, now I know! Thanks!
Report Abuse
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
01 Sep 2011 12:13 AM
Now it works perfectly! :D
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