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: Need a lil help here

Previous Thread :: Next Thread 
Makumio is not online. Makumio
Joined: 10 Aug 2012
Total Posts: 54
14 Sep 2016 06:11 AM
How would I loop a damage script whilst the enemy is inside the brick which is the hitbox.

I have this script but it is not very efficient because if you stop moving the damage will stop as well. Is it possible to loop the damage whilst touching the brick and stop till the player stops touching the brick.

function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
human.Health = human.Health - 0.5
end
end

script.Parent.Touched:connect(onTouched)

Thanks

Makumio
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
14 Sep 2016 06:14 AM
While true do
if human ~= nil then
hum.Health = hum.Health - .5

http://wiki.roblox.com/?title=Loops
Report Abuse
WoolHat is online. WoolHat
Joined: 19 May 2013
Total Posts: 1873
14 Sep 2016 07:41 AM
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=198280060

The first one is more efficient, so to speak. I plan on improving it by passing a function as a variable, but until then, that's a good bet. You'll have to manipulate some of the code (like "torso" being the only valid touching part. I did that so the script doesn't run double when a player steps on it with both feet.
Report Abuse
CodeBreadpudding is not online. CodeBreadpudding
Joined: 24 Aug 2016
Total Posts: 1286
14 Sep 2016 07:51 AM
local d = false

script.Parent.Touched:connect(function(p)
if p.Parent.Humanoid then
d = true
while d do
p.Parent.Humanoid.Health = p.Parent.Humanoid.Health - 10
wait(1)
end
end
end)

script.Parent.TouchEnded:connect(function(p)
if p.Parent.Humanoid then
d = false
end
end)
Report Abuse
ManxFox is not online. ManxFox
Joined: 12 Nov 2008
Total Posts: 227
14 Sep 2016 07:59 AM
^ @Above Post

Didn't even know TouchEnded Existed, that's a helpful little thing!
Thanks for that actually.


Report Abuse
Mitko0o1 is not online. Mitko0o1
Joined: 30 Nov 2010
Total Posts: 5725
14 Sep 2016 08:08 AM
##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
Report Abuse
Mitko0o1 is not online. Mitko0o1
Joined: 30 Nov 2010
Total Posts: 5725
14 Sep 2016 08:08 AM
wow these hashtags, i give up
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
14 Sep 2016 08:10 AM
^pastebin
Report Abuse
ManxFox is not online. ManxFox
Joined: 12 Nov 2008
Total Posts: 227
14 Sep 2016 08:11 AM
Forum doesn't like pastebin and hashtags it too :L


Report Abuse
Mitko0o1 is not online. Mitko0o1
Joined: 30 Nov 2010
Total Posts: 5725
14 Sep 2016 08:14 AM
paste bin: vbKj0gMT
Report Abuse
ManxFox is not online. ManxFox
Joined: 12 Nov 2008
Total Posts: 227
14 Sep 2016 08:15 AM
*claps* I stand corrected, I guess the forum just hates me then, lol.


Report Abuse
Makumio is not online. Makumio
Joined: 10 Aug 2012
Total Posts: 54
14 Sep 2016 08:22 AM
Thanks everyone this has helped me and finally mobs have a working hitbox that can no longer be avoided by trapping them on other objects.

Thanks a bunch

Makumio
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