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: if hit.Name == "" Error.. Help?

Previous Thread :: Next Thread 
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 04:44 PM
So, my script works perfectly, except for this...

if hit.Name == "Pea" then

end

I've checked out several forums and tried EVERYTHING!!! It just cannot do it! I think I'm doing the "if" statement wrong... Help?
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
01 Oct 2015 04:47 PM
It's fine. What is the error?

-The [Guy]
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
01 Oct 2015 04:50 PM
Post the entire code, if that's all the error is obvious.

hit is nil.
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 04:51 PM
That's the problem, there IS no error. It just doesn't do anything.
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 04:52 PM
The script is

function onTouched(hit)
if hit.Name == "Pea" then --Won't work...
hit:Destroy()
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
01 Oct 2015 04:54 PM
make sure the object is named "Pea" and not "pea" or some silly inconsistency like that?

-The [Guy]
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
01 Oct 2015 04:54 PM
function onTouched(hit)
if hit:IsA("BasePart") and hit.Name == "Pea" then --Won't work...
hit:Destroy()
print("Destroyed!")
elseif hit:IsA("BasePart") then
print('Brick got touched but it's not being destroyed. Instance:"'..hit.Name..'"')
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 04:57 PM
1. Yes, the part is named "Pea".


2. That script did not work.
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
01 Oct 2015 04:58 PM
Thanks, i would like to hear what it prints.
Report Abuse
Elandorr is not online. Elandorr
Joined: 25 Sep 2015
Total Posts: 148
01 Oct 2015 05:02 PM
Script isn't disabled by chance is it?
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 05:04 PM
It printed nothing...
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 05:05 PM
1. No, it's not disabled
Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
01 Oct 2015 05:07 PM
Is the part touching it called Pea, or is the part in which the script itself is located called Pea?
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 05:09 PM
The part touching it is called pea
Report Abuse
Elandorr is not online. Elandorr
Joined: 25 Sep 2015
Total Posts: 148
01 Oct 2015 05:12 PM
@cross haha see! its called "pea" not "Pea" change the name of the brick to "Pea"!
Report Abuse
recursionoid is not online. recursionoid
Joined: 03 Jun 2010
Total Posts: 47
01 Oct 2015 05:13 PM
is it a serversided script or a localscript
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 05:14 PM
1. What? The part is called "Pea"... Idk what you're getting at...


2. Global script, not local
Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
01 Oct 2015 05:15 PM
function onTouched(part)
if part.Name == "Pea" then --Won't work...
part:Destroy()
end
end

script.Parent.Touched:connect(onTouched)



try this???
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 05:19 PM
That's just like my original script. No, it did not work
Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
01 Oct 2015 05:21 PM
i changed a variable
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
01 Oct 2015 05:22 PM
Is this a joke to get us to go in circles, or...

-The [Guy]
Report Abuse
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
01 Oct 2015 05:23 PM
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
01 Oct 2015 05:25 PM
Don't lisent to ninja, he don't have any idea at what he's saying.

However, is the part who's touching it NOT anchored?
Report Abuse
cross700 is not online. cross700
Joined: 20 Oct 2012
Total Posts: 258
01 Oct 2015 05:26 PM
"Pea" (the part that's touching) IS anchored
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
01 Oct 2015 05:27 PM
Oh. Is the part that's detecting a touch anchored also?

-The [Guy]
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