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
|
  |
| Joined: 07 Aug 2014 |
| Total Posts: 11158 |
|
|
| 24 Jan 2015 03:05 PM |
script.Parent.Touched:connect(function()
end) |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 24 Jan 2015 03:38 PM |
@forever
the hit argument would actually be the part that HIT your brick |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 03:39 PM |
| yeah ik thats what i said / meant |
|
|
| Report Abuse |
|
|
| |
|
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 |
|
|
|
| 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
|
  |
| Joined: 09 Feb 2009 |
| Total Posts: 384 |
|
|
| 24 Jan 2015 03:55 PM |
| yeah i get that reversed a lot, sorry |
|
|
| Report Abuse |
|
|
Kaboom680
|
  |
| Joined: 09 Feb 2009 |
| Total Posts: 384 |
|
| |
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|