Today I come to you seeking advice on something strange I’ve encountered. So I’m trying to run animations locally and teleport a player when they use an ability called “Tunnel”. They play a single animation which makes them jump into an entrance tunnel, then jump out of an exit tunnel. The problem is the behavior seen on the player (right) is different from what’s seen on the enemy’s end (left). To the enemy, you seem to play the full animation and then teleport. But that’s not how it plays out locally.
Note: These functions are called from another module. If you’re the player Tunneling, you play the animation in module:Ability3. If you’re not, you skip that part. ability3_exitVisible() is called only for the players not doing the Tunneling, to make the exit tunnel visible at the appropriate time. If you’re the one Tunneling, you play the animation, anchor your own root, teleport at the appropriate keyframe, then un-anchor yourself when you exit.
I think i’d need to do some hands on testing to see the issue. In the GIF everything seems fine for the localplayer, with the issue appearing for the enemy (player 2) who sees the camera float to the other.
EDIT: Oh I see the issue, on the client it plays the animation while teleporting (i.e on both ends) while on other clients (i.e enemy) it plays it all on one then shifts you. Most likely as your character is anchored so it causes weird replication.
I feel as if your response was a little condescending. I’m aware of what lag is, and I feel like it’s pretty clear the issue isn’t simply latency based on the code I provided, the description of the code, and the video depicting a very long delay between the teleports.
Apparently the issue ended up being that parts anchored on the client’s end don’t replicate across the server to other clients. In this case I’m anchoring the player’s root on the client, so it doesn’t replicate until I un-anchor the root again at the end of the animation. Lag is not the answer in this particular case. This has been fixed by moving the anchoring process to the Server module.
For anyone looking back at this. Remote Events aren’t themselves exploitable - if you assume the data the client is giving you is “truth” then you can open yourself up to abuse though.
For instance in RoCitizens they used to have an issue where they accepted however much money the client said it deserved as “Truth”. But as long as you validate receiving data and make sure you’re working off a Server Authorative Model, you’re fine.