Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I deal with touch event lag to make an effect on the touch position?

Asked by 5 years ago
Edited 5 years ago
part = script.Parent

part.Touched:connect(function()
    if not part.Anchored then
        part.Anchored
    end
end)

This is the most basic example. Imagine i want to anchor the part exactly when it hit another part. In a server it lags so the part gets anchored a bit later resulting in it being anchored many times inside the part that it hit.

I want to deal find a way to deal with that lag so i add a couple of effects when certain parts hit others. For example, an explosion. To do that i want the position of the part when it hit:

part = script.Parent
debounce = false

part.Touched:connect(function()
    if not debounce then
        debounce = true
        position = part.Position
    end
end)

But then again, the touch event is delayed and i get a position that i don't want, a position that corresponds for example to one where the part already got inside of the part it hit as a result of the lag once again.

So does anyone have any idea how to deal with this?

I see for example in NO2 of Snakeworl explosion effects happening as a result of attacks hitting walls.. When i try to replicate that, my effects get inside the walls in the servers because of the lag i've talked about.

0
I've seen it, it helped me to deal with projectile lag, and there's a little about dealing with touch event lag. However in my case the problem is getting the touch position or something of that sort, for example the position of the projectile in the instand of touching, so i can then add and effect in that position Kiriyato 15 — 5y
0
I can post an example of a script where the lag interferes, but i think its useless Kiriyato 15 — 5y
0
get the position of the projectile when it hits something, the first parameter returned by the touched event is what it touched, so use some vector math to find the projectile's position relative to the object hit... is that how you are doing it? (maybe you should post the script) fanofpixels 718 — 5y
View all comments (5 more)
0
Okay i changed the whole description of my question Kiriyato 15 — 5y
0
try adding debounce cmgtotalyawesome 1418 — 5y
0
try adding debounce cmgtotalyawesome 1418 — 5y
0
try adding debounce cmgtotalyawesome 1418 — 5y
0
debounce ain't the problem, what does that have to do with anything? but sure ill add the debounce in the question description so no one else points it out Kiriyato 15 — 5y

Answer this question