|
| 28 Sep 2013 06:26 PM |
I need help to fix this script. It if you touch it and you have humanoid, it will print ("hi").
function touched(hit) if hit.Parent.Humanoid ~= nil then print ("hi") end
script.Parent.Touched:connect (touched) |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 28 Sep 2013 06:27 PM |
| that should work but ~= nil is redundant |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:27 PM |
| if hit.Parent:FindFirstChild("Humanoid") then |
|
|
| Report Abuse |
|
|
your90
|
  |
| Joined: 06 Mar 2011 |
| Total Posts: 1380 |
|
|
| 28 Sep 2013 06:28 PM |
function onTouched(hit) if hit.Parent.Humanoid ~= nil then print("Hi.") end end script.Parent.Touched:connect(onTouched)
--DONT COPY THIS 1st end = end function 2nd end = end if |
|
|
| Report Abuse |
|
|
your90
|
  |
| Joined: 06 Mar 2011 |
| Total Posts: 1380 |
|
|
| 28 Sep 2013 06:28 PM |
I forgot
if hit.Parent:findFirstChild("Humanoid") ~= nil then |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:28 PM |
| I never actually had this script in my place. I just wanted to make sure if that was how you detect humanoid without asking the question directly. |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:29 PM |
"if hit.Parent.Humanoid" >Going to break if hit by a non-humanoid |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:30 PM |
| How do you make it so if the name of the brick that hits it is named "Bullet"? |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:30 PM |
| if hit.Name == "NAMEHERE" then |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:31 PM |
That was close I thought it was
if hit.Parent.Name == "NAME" then
oh well |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:32 PM |
So this would work?
function touched(hit) if hit.Name == "NAMEHERE" then print ("hi") end
|
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:32 PM |
| hit.Parent would be the thing it`s in... |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:43 PM |
| So how would I change it up? |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:43 PM |
| Wait. I'm confused. Was that script correct? |
|
|
| Report Abuse |
|
|
Xeptix
|
  |
| Joined: 14 Mar 2013 |
| Total Posts: 1115 |
|
|
| 28 Sep 2013 06:46 PM |
function touched(hit) if hit.Parent:findFirstChild("Humanoid") then print ("hi") end end
script.Parent.Touched:connect (touched) |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2013 06:48 PM |
hit.Name - The name of the thing that hit it hit.Parent.Name - The name of the thing its in example A part named A in a model named "Model" hits another part B Assuming the script is in part B: Hit.Name would return part A hit.Parent.Name would return model "Model" assuming the model is in the workspace: hit.Parent.Parent.Name would return "Workspace" |
|
|
| Report Abuse |
|
|