Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 01 Apr 2017 04:39 PM |
This code is inside of a projectile that is supposed to damage enemies it hits. You can use this H@ste bin link (/afezuvujow.lua) or read below. This problem is very annoying and I need a solution asap.
local debounce = true math.randomseed(tick()) wait()
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Target') and debounce then debounce = false local player = script.Parent.plr.Value hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - (script.Parent.damage.Value + math.random(-5, 5)) if hit.Parent.Attackers:FindFirstChild(script.Parent.plr.Value) then else local newAttackerInstance = Instance.new("StringValue", hit.Parent.Attackers) newAttackerInstance.Name = script.Parent.plr.Value end script.Parent:Destroy() else end end) |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
Thedagz
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 798 |
|
| |
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 01 Apr 2017 06:25 PM |
| I already built my framework around lerping projectiles. IIRC .Touched should work fine for this, yet it does not register certain collisions. |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2017 06:31 PM |
| You never set debounce back to true |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2017 06:34 PM |
change the framework it'll save you more
capitalist atheist |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 01 Apr 2017 06:43 PM |
| ########### Don't need to #### For what I'm doing it shouldn't really matter too much. I don't want hitscan and this was the first thing that came to mind. Just trying to get this working. |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 01 Apr 2017 06:46 PM |
A) You never set debounce back to true B) If you're lerping the part's CFrame it won't trigger touched. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 01 Apr 2017 06:55 PM |
| ########## A: Because it is only supposed to hit one thing and then delete itself. B: I didn't know that. Any work arounds? |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 01 Apr 2017 06:56 PM |
Should I use magnitude instead?
|
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 01 Apr 2017 06:59 PM |
| Don't lerp the object, make it unanchored and move it with bodymovers. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 01 Apr 2017 07:02 PM |
| If you don't mind me asking, what are the advantages and disadvantages of lerping and using bodymovers, for future reference |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 01 Apr 2017 07:09 PM |
Varies with circumstance. Here, since you want to used Touched then you NEED roblox to handle the object's physics since that's what calculates collisions and fires Touched. Since you're lerping the part, you're basically handling the part's physics, but you aren't calculating collisions or firing Touched. Other things can fire Touched in the latter scenario, but Touched is fired from their physics calcs (they must be moving and probably some other things to consider). It's just more reliable if ROBLOX is handling physics if you want to use physical events.
If you want to lerp the part, then you'll want to hit-scan over small arcs. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
| |
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 01 Apr 2017 09:29 PM |
| pls elaborate I don't use renderstepped much |
|
|
| Report Abuse |
|
|
| |
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
|
| 01 Apr 2017 10:46 PM |
use body movers so it can actually collide with things
if not then learn how to math correctly and then raycast .-.
touched will only fire once an object is within another, meaning if you lerp and it misses the object then it wont do anything |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 01 Apr 2017 11:34 PM |
| ^^Also won't do anything if it overlaps with a sleeping part. |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2017 11:35 PM |
| it will if you know how to raycast correctly and raycast before the part just in case |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 01 Apr 2017 11:39 PM |
| I was adding on to "touched will only fire once an object is within another, meaning if you lerp and it misses the object then it wont do anything" |
|
|
| Report Abuse |
|
|