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 » Scripters
Home Search
 

Re: new to scripting need help with .touched

Previous Thread :: Next Thread 
Kaboom680 is not online. Kaboom680
Joined: 09 Feb 2009
Total Posts: 384
24 Jan 2015 03:01 PM
so, i'm trying to insert a .Touched script into a block that i made with a script, but
script.Parent.Touch:connect(.Touched)
isn't working with this
i can't find anything on the wiki, what do i do to connect the function to the block that's being made?
Report Abuse
xLink123 is not online. xLink123
Joined: 07 Aug 2014
Total Posts: 11158
24 Jan 2015 03:05 PM
script.Parent.Touched:connect(function()

end)
Report Abuse
025110 is not online. 025110
Joined: 23 Nov 2012
Total Posts: 57661
24 Jan 2015 03:06 PM
script.Parent.Touched:connect(function(p)
if p:FindFirstChild("Humanoid") then
--code here
end)


R$3,055
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
24 Jan 2015 03:23 PM
@025110
You forgot an end and there will not be a humanoid in p because p is the part that touched it and the players Right Arm, Leg, Torso,Head, and so on, do not have a humanoid in them
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
24 Jan 2015 03:23 PM
This is the type I'd make...

script.Parent.onTouch:connect(function()

end)
Report Abuse
Kaboom680 is not online. Kaboom680
Joined: 09 Feb 2009
Total Posts: 384
24 Jan 2015 03:30 PM
@cross
@025
do i just stick it on the end or what
i'm practically illiterate with this
Report Abuse
Kaboom680 is not online. Kaboom680
Joined: 09 Feb 2009
Total Posts: 384
24 Jan 2015 03:35 PM
also i mean maybe i didn't describe my situation well enough but
i have 2 scripts, one is for the damage on the brick, and the other is for making the bricks. i already have the scripts inserted to the brick and enabled, but the scripts give me the error
"16:35:01.390 - Touched is not a valid member of Tool"
the script is in the tool, but the clone of the script which is in the brick doesn't seem to be working for this reason
Report Abuse
warycapdecutie is not online. warycapdecutie
Joined: 13 Aug 2010
Total Posts: 14373
24 Jan 2015 03:35 PM
you can create a normal function or an anonymous function

this is the shorter variant of creating a function with the touched event, an anoynymous function.

script.Parent.Touched:connect(function(partthattouched)
--code
end)


if you want it to work with script.Parent, place the script inside the brick. this is the most simple variant


otherwise, (you might or might not find this more complicated), create a variable with the value of it being the path to the brick, like this:

brick = game.Workspace.Brick --- you can change this to wherever you can find the brick

brick.Touched:connect(function(partthattouched)
--code
end)

if you have more questions regarding this, i'll try to do my best to explain this to you




Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
24 Jan 2015 03:37 PM
what cross said won't work

script.Parent.Touched:connect(function(hit)
--code (hit is the object that was touched)
end)
Report Abuse
warycapdecutie is not online. warycapdecutie
Joined: 13 Aug 2010
Total Posts: 14373
24 Jan 2015 03:38 PM
@forever

the hit argument would actually be the part that HIT your brick
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
24 Jan 2015 03:39 PM
yeah ik thats what i said / meant
Report Abuse
warycapdecutie is not online. warycapdecutie
Joined: 13 Aug 2010
Total Posts: 14373
24 Jan 2015 03:41 PM
@forever

oh
Report Abuse
Kaboom680 is not online. Kaboom680
Joined: 09 Feb 2009
Total Posts: 384
24 Jan 2015 03:52 PM
alright friends this just isn't working out
i'm just gonna copypaste the code and a part of the other code
the scripts name is Damage147
------------------------------- Code that i need fixed with the end part i guess
function onTouch(part)
if part.Parent:FindFirstChild("Humanoid")~= nil then
script.Disabled = false
for i = 1,1 do
part.Parent.Humanoid.Sit = true
part.Parent.Humanoid.Health = part.Parent.Humanoid.Health - 25
wait()
end
end
wait()
script.Disabled = true
end
script.Parent.Touched:connect(function(part)
end)
------------------------------------ Section of code that makes the bricks

local s =Tool.Damage147:clone()
s.Disabled = false
------------------------------------ Section of code that makes the bricks
s.Parent=Fissure7



sorry friends



Report Abuse
warycapdecutie is not online. warycapdecutie
Joined: 13 Aug 2010
Total Posts: 14373
24 Jan 2015 03:53 PM
for 1, the start part of your script is trying to use the script when it's disabled
i dont see how that would work
Report Abuse
Kaboom680 is not online. Kaboom680
Joined: 09 Feb 2009
Total Posts: 384
24 Jan 2015 03:55 PM
yeah i get that reversed a lot, sorry
Report Abuse
Kaboom680 is not online. Kaboom680
Joined: 09 Feb 2009
Total Posts: 384
24 Jan 2015 04:31 PM
any help?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
24 Jan 2015 04:33 PM
Don't bother setting script.Disabled, especially here. There is absolutely no reason to do it here.
Report Abuse
Kaboom680 is not online. Kaboom680
Joined: 09 Feb 2009
Total Posts: 384
24 Jan 2015 04:56 PM
i mean, with the ending on script 1, Damage147, but thanks for the tip
Report Abuse
Kaboom680 is not online. Kaboom680
Joined: 09 Feb 2009
Total Posts: 384
24 Jan 2015 05:20 PM
wow, i'm really stupid. Sorry guys, yeah wary thank you, i didn't understand what your section meant. i get it now kinda.

/thread
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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