I’m a new scripter that’s hoping to make my first game on ROBLOX. However, a huge problem in my game is the lag in the game. I have read this article about lag however I still do not understand it.
My Problem
I have a sword tool and when you click, it fires a remote and that remote plays the animations/effects and enables some values for the damage server script to deal damage. The damage server script checks the player’s stats and if a certain value is true, damage can be dealt and that’s how I’m doing it. The damage server script doesn’t have any lag since I’m looping it however the swinging is the problem.
How I tried to deal with it
I have read other posts about how I need to “split the work between the client and the server” however I don’t understand how to “split the work.” At first, I figured that the equipping and the unequip animation could just be on a local script so I did that. The problem is with the swing animation.
When I try to make something, I always keep exploiters in mind. If I don’t add a check such as a value or something, the animation could just be played over and over again. I’m not sure if that’s good but when I try to add a check in local script, “if value == true then” there is delay between the mouse click and the animation playing. It doesn’t feel smooth. With that much delay, I might as well just put everything on a server script and run that. The delay is basically the same. Also, when I swing the sword, a trail is enabled and the damage value that the server checks is enabled allowing the player to damage another player and it turns off after the animation stops playing. If I’m trying to “split the work”, I’m thinking that I need to put everything visual on the local script and everything that is important on the server script. However, how do I activate the sword trail so everyone in the game can see it? I’m honestly confused.
What I’m trying to achieve
I’m trying to make a sword tool that swings without delay and works perfectly fine. It also shows every player in the game the sword trails and also have a working cooldown. (I’m not sure if I’m right but I think cooldowns do not work on localscripts since it can’t set values that replicate to server, and I don’t want to have a remote just to do that since exploiters could just loop fire that remote and disable cooldown.)
There aren’t any videos on youtube teaching you how to fix this issue either. Can someone please explain to me how I can achieve my goal?