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: Script

Previous Thread :: Next Thread 
ninja900500 is online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
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 is not online. janthran
Joined: 15 May 2009
Total Posts: 17429
28 Sep 2013 06:27 PM
that should work but ~= nil is redundant
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
28 Sep 2013 06:27 PM
if hit.Parent:FindFirstChild("Humanoid") then
Report Abuse
your90 is not online. 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 is not online. 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
ninja900500 is online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
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
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
28 Sep 2013 06:29 PM
"if hit.Parent.Humanoid"
>Going to break if hit by a non-humanoid
Report Abuse
ninja900500 is online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
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
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
28 Sep 2013 06:30 PM
if hit.Name == "NAMEHERE" then
Report Abuse
ninja900500 is online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
28 Sep 2013 06:31 PM
That was close I thought it was

if hit.Parent.Name == "NAME" then

oh well
Report Abuse
ninja900500 is online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
28 Sep 2013 06:32 PM
So this would work?

function touched(hit)
if hit.Name == "NAMEHERE" then
print ("hi")
end
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
28 Sep 2013 06:32 PM
hit.Parent would be the thing it`s in...
Report Abuse
ninja900500 is online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
28 Sep 2013 06:43 PM
So how would I change it up?
Report Abuse
ninja900500 is online. ninja900500
Joined: 27 Sep 2008
Total Posts: 2324
28 Sep 2013 06:43 PM
Wait. I'm confused. Was that script correct?
Report Abuse
Xeptix is online. 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
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
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
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