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: On touched function won't work

Previous Thread :: Next Thread 
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
31 Aug 2011 11:54 PM
Okay, by the looks of this you'll probably know what I'm trying to do. now how do I make it work?


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

script.Parent.Touched:connect(onTouched)


Thanks a bunch!
Report Abuse
getkoed is not online. getkoed
Joined: 18 Feb 2010
Total Posts: 2298
31 Aug 2011 11:56 PM
If you want the brick unanchored if it's not locked:

script.Parent.Touched:connect(function()
if (script.Parent.Locked ~= false) then
script.Parent.Anchored = false
end)

-- OR --

function onTouched()
if (script.Parent.Locked ~= false) then
script.Parent.Anchored = false
end

script.Parent.Touched:connect(onTouched)

----

The two scripts are the same, but I use the first one, it's shorther than the 2nd... :3
Report Abuse
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
31 Aug 2011 11:59 PM
Thank you!
Report Abuse
Ghillie3 is not online. Ghillie3
Joined: 22 Aug 2011
Total Posts: 10
01 Sep 2011 12:00 AM
Wait, but I don't want the script parent to be affected, I want what it's touching to be affected.
Report Abuse
getkoed is not online. getkoed
Joined: 18 Feb 2010
Total Posts: 2298
01 Sep 2011 12:10 AM
The toucher = affected?

Unanchors all parts of toucher
===================

script.Parent.Touched:connect(function(hit)
p = hit.Parent:GetChildren()
for i = 1, #p do
if (p[i].className == "Part") then
p[i].Anchored = false
end
end
end)

Kills the toucher
==========

script.Parent.Touched:connect(function(hit)
local h = hit.Parent:findFirstChild("Humanoid")
if (h ~= nil) then
h.Health = 0
end
end)

Freezes the toucher
============

script.Parent.Touched:connect(function(hit)
local h = hit.Parent:findFirstChild("Humanoid")
if (h ~= nil) then
h.WalkSpeed = 0
end
local p = hit.Parent:GetChildren()
for i = 1, #p do
if (p[i].className == "Part") then
p[i].Reflectance = 1
end
end
end)

Makes toucher invisible
==============

script.Parent.Touched:connect(function(hit)
local p = hit.Parent:GetChildren()
for i = 1, #p do
if (p[i].className == "Part") then
p[i].Transparency = 1
end
end
end)

I don't know really of all these scripts work, because I didn't test them, but I guess they will.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
01 Sep 2011 12:12 AM
function onTouched(part)
if part.Locked == false then
part.Anchored = true --this was the line. It's part.Anchored not part:Anchored.
end end
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
01 Sep 2011 12:14 AM
LP, my bad.
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