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: Why does this work one time then break?

Previous Thread :: Next Thread 
Scripbuilder900 is not online. Scripbuilder900
Joined: 04 Aug 2011
Total Posts: 183
17 Aug 2011 09:47 PM
function onTouched(hit)
game.Workspace.Player.Head:Remove()
end
script.Parent.Touched:connect(onTouched)



--My suspicion is if the Torso Touches it then it breaks. If that were the case how could you prevent it?
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
17 Aug 2011 09:49 PM
function onTouched(hit)
if game.Workspace:findFirstChild("Player") then
game.Workspace.Player:BreakJoints()
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
Scripbuilder900 is not online. Scripbuilder900
Joined: 04 Aug 2011
Total Posts: 183
17 Aug 2011 09:49 PM
I dont want the script i want to know why mine didnt work
Report Abuse
MXrcr20 is not online. MXrcr20
Joined: 01 Oct 2008
Total Posts: 2644
17 Aug 2011 09:49 PM
function onTouched(hit)
h=hit.Parent:findFirstChild("Head")
if h then
h:Remove()
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
Scripbuilder900 is not online. Scripbuilder900
Joined: 04 Aug 2011
Total Posts: 183
17 Aug 2011 09:53 PM
I fixed it all by simply saying
function onTouched(hit)
game.Workspace.Player.Humanoid.Health = 0
end
script.Parent.Touched:connect()

the fact that I have to do this is stupid it should work both ways
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
17 Aug 2011 09:55 PM
No, it's not. It's because you didn't have debounce in your first script, and that script will STILL error.

When you touch a brick, it runs 2ce because both legs hit it. Because it runs 2ce, the first time it will remove 'Player's' Head. The 2nd time, the output sohuld say 'Head' is a nil value, because it already had been removed.
Report Abuse
MXrcr20 is not online. MXrcr20
Joined: 01 Oct 2008
Total Posts: 2644
17 Aug 2011 09:56 PM
.Touched scripts with no debounce will run more than twice when you touch them...
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
17 Aug 2011 09:58 PM
Well, usually it runs 2ce because 2 legs touch them, but yes as you're moving off the brick you'll touch them again.
Report Abuse
bloob827 is not online. bloob827
Joined: 01 Aug 2010
Total Posts: 6867
17 Aug 2011 09:59 PM
script.Parent.Touched:connect(pcall(function(l)
game.Players:getPlayerFromCharacter(l).Torso:remove()
end)end)
Report Abuse
MXrcr20 is not online. MXrcr20
Joined: 01 Oct 2008
Total Posts: 2644
17 Aug 2011 09:59 PM
In my output, it runs a script like 15 times with no debounce.
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