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: .Touched function only fires ~1/30 times.

Previous Thread :: Next Thread 
Fangous is not online. 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 is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
01 Apr 2017 05:02 PM
bump
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
01 Apr 2017 05:26 PM
bump
Report Abuse
Thedagz is not online. Thedagz
Joined: 10 Mar 2012
Total Posts: 798
01 Apr 2017 05:35 PM
Use raycast for collision
Report Abuse
Fangous is not online. 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
cowsoncows is not online. cowsoncows
Joined: 11 Oct 2013
Total Posts: 2522
01 Apr 2017 06:31 PM
You never set debounce back to true
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
01 Apr 2017 06:34 PM
change the framework it'll save you more


capitalist atheist
Report Abuse
Fangous is not online. 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 is not online. 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 is not online. 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 is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
01 Apr 2017 06:56 PM
Should I use magnitude instead?
Report Abuse
Casualist is not online. 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 is not online. 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 is not online. 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 is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
01 Apr 2017 07:53 PM
bump
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
01 Apr 2017 08:32 PM
bump
Report Abuse
szkiller_dev is not online. szkiller_dev
Joined: 07 Oct 2016
Total Posts: 3572
01 Apr 2017 09:07 PM
Maybe use render stepped
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
01 Apr 2017 09:29 PM
pls elaborate I don't use renderstepped much
Report Abuse
szkiller_dev is not online. szkiller_dev
Joined: 07 Oct 2016
Total Posts: 3572
01 Apr 2017 09:39 PM
Lol ok...



Free bump :D
Report Abuse
Fangous is not online. Fangous
Joined: 03 Jul 2010
Total Posts: 4448
01 Apr 2017 10:04 PM
?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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 is not online. 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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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 is not online. 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
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