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: What the heck is wrong with my script?

Previous Thread :: Next Thread 
Hergest is not online. Hergest
Joined: 17 May 2011
Total Posts: 309
31 Dec 2012 08:24 PM
So basically i started learning Lua and i love it. So i tried to create a reset brick.
Here is my script:

function onTouched()
game.Workspace.Hergest.Head:remove()
end
script.Parent.Touched(onTouched)

So.. What did exactly do wrong?
Report Abuse
Z007 is not online. Z007
Joined: 14 Sep 2010
Total Posts: 11729
31 Dec 2012 08:26 PM
This should work.
function onTouched()
game.Workspace.Hergest.Head:Remove()
end
script.Parent.Touched:connect(onTouched)
Report Abuse
ninja5566 is not online. ninja5566
Joined: 14 Jan 2009
Total Posts: 5233
31 Dec 2012 08:27 PM
script.Parent.Touched:connect(function(hit)
player = game.Players:getPlayerFromCharacter(hit.Parent)
if player ~= nil then
a = hit.Parent:findFirstChild("Humanoid")
if a ~= nil then
a.Parent.Head:Destroy()
end end end)
Report Abuse
Hergest is not online. Hergest
Joined: 17 May 2011
Total Posts: 309
31 Dec 2012 08:41 PM
ZOO, your script didn't work. :/ Ninja's script did but it's too confusing for me. I'm supposed to learn. :P
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
31 Dec 2012 08:58 PM
I'll try to make it easier...

function onTouched(hit) --hit is the part that hit
if hit.Parent:FindFirstChild("Humanoid") then --checks if a human hit the brick
hit.Parent.Head:Destroy() --Removes the head
end
end

script.Parent.Touched:connect(onTouched)


That should work. I hope I simplified it for you.
Report Abuse
ninja5566 is not online. ninja5566
Joined: 14 Jan 2009
Total Posts: 5233
31 Dec 2012 09:00 PM
function touched(hit) --Hit, is the object touched.
humanoid = hit.Parent:findFirstChild("Humanoid") --It must have a humanoid
if humanoid ~= nil then --If humanoid is real then it will find the head and kill it
humanoid.Parent.Head:Destroy() --Finding the head and destroying it.
end
end
script.Parent.Touched:connect(touched)


The only reason my other one was advanced because I was making sure if it was hit it is a REAL player not a fake block with a humanoid in it, for example if a block with a humanoid hit it, it would break the script.
Report Abuse
doneyes is not online. doneyes
Joined: 21 Mar 2008
Total Posts: 3466
31 Dec 2012 09:24 PM
If you are testing it in studio, notice your name is Player1.
Report Abuse
zack785 is not online. zack785
Joined: 06 Feb 2009
Total Posts: 419
31 Dec 2012 09:37 PM
script.Parent.Touched:connect(function(hit) --It's the function onTouch thing in different wording
player = game.Players:getPlayerFromCharacter(hit.Parent) --The person that touched that; it checks if it's a person in Players too
if player ~= nil then
a = hit.Parent:findFirstChild("Humanoid") --Basically making sure whoever touched it has a humanoid
if a ~= nil then --it means if there is a Humanoid
a.Parent.Head:Destroy() --a(Humanoid).Parent(so the person) and the goes to there head and destroys it, I perfer a.Parent.Head:remove()
end end end)
Report Abuse
zack785 is not online. zack785
Joined: 06 Feb 2009
Total Posts: 419
31 Dec 2012 09:38 PM
their* not there
Report Abuse
zack785 is not online. zack785
Joined: 06 Feb 2009
Total Posts: 419
31 Dec 2012 09:40 PM
Did my explanation help at all?
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