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
 

How do I make this loopkill script repeat?

Previous Thread :: Next Thread 
M16Micah is not online. M16Micah
Joined: 04 Apr 2009
Total Posts: 891
16 Jun 2010 09:04 PM
function stringcheese(hit)
if hit.Parent.Name == "your name here" then
hit.Parent.Head:remove()
end
end
script.Parent.Touched:connect(stringcheese)
Report Abuse
mako123 is not online. mako123
Joined: 18 Dec 2008
Total Posts: 1125
16 Jun 2010 09:07 PM
function stringcheese(hit)
if hit.Parent.Name == "your name here" then
while true do
hit.Parent.Head:remove()
end
end
end
script.Parent.Touched:connect(stringcheese)

Nice function name btw :P
Report Abuse
xXxXxdragonxXxXx is not online. xXxXxdragonxXxXx
Top 100 Poster
Joined: 30 Dec 2008
Total Posts: 30113
16 Jun 2010 09:10 PM
@mako

You need wait() or game will crash without wait().
Report Abuse
mako123 is not online. mako123
Joined: 18 Dec 2008
Total Posts: 1125
16 Jun 2010 09:13 PM
Oh, forgot xD.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
16 Jun 2010 09:14 PM
Bit more complicated than that:


function stringcheese(hit)
if hit.Parent.Name == "your name here" then
local player = game.Players[hit.Parent.Name]
coroutine.resume(coroutine.create(function()
while wait() do
if player.Character:FindFirstChild("Torso") then
player.Character.Head:remove()
end
end))
end
end

script.Parent.Touched:connect(stringcheese)
Report Abuse
mako123 is not online. mako123
Joined: 18 Dec 2008
Total Posts: 1125
16 Jun 2010 09:15 PM
Oh yeah, because the script would error out if there was no head to remove.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
16 Jun 2010 09:16 PM
Yes and a coroutine make sure that the script can still run for other players. If you just use a while loop, it will never fire the touched event again.
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