Lag Problems With My Game Quirks

Today I was creating some quirks for my upcoming game and I realized that I was having some problems. Basically I was creating an energy ball/ki script and I realized that the energy ball was spawning in front of my hand instead on it. I thought I had done something wrong in my script but nope. And not only that but the ball froze for like 1 second in my hand and then it started moving. It was a really huge delay. Then I decided to transfer network ownership to the client through :SetNetworkOwner() as I thought that might make a difference, and it did! (ignore the head)
https://gyazo.com/2847b44c8e6c1c5cdea29673d5885e9c
I feared that using :SetNetwork(player) would cause lag for the other clients and the quirk would look really bad. And I was right. The quirk looked awful for the other clients. The energy ball froze on the hand for some seconds and then decided to move extremely fast in a glitchy way. I have been trying pretty much everything to fix this problem but I am not sure what I am doing wrong. Script inside server script:

--x is mouse.Hit and rh righthand
        local ball = Instance.new("Part")
        ball.Shape = "Ball"
        ball.BrickColor = BrickColor.new("Cyan")
        ball.Material = Enum.Material.Neon
        ball.CanCollide = false
        ball.Size = Vector3.new(2.5, 2.5, 2.5)
        ball.Position = rh.Position + Vector3.new(0, 0, 0)
        local velocity = Instance.new("BodyVelocity")
        velocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
        velocity.Velocity = x.lookVector * 500
        ball.Parent = workspace
		ball:SetNetworkOwner(plr)
        velocity.Parent = ball
		game:GetService("Debris"):AddItem(ball, 1)

Basically what I do is play an animation, then when the animation is played I fire a remote event.

2 Likes

Your post is quite cluttered, it’s hard to comprehend :grimacing:

So the issue is lag or the ball spawning infront of the character?

1 Like

I think that the lag is causing these issues, so lag.

1 Like

rh is right hand, x is mouse.Hit, I already said that in the script, it is a comment at the top of the script.

Uh, try making the max force smaller? I’ve experienced issues with body forces at extreme speeds.

I have already tried that. The energy ball moves really slow and in the wrong direction.

It’s kind of a simple but complex issue.

On the client, you have a function hooked to the event to do the visuals, and on the server you do the actual hit detection.

Basically it goes like this

  1. Client clicks
  2. Client sees effects
  3. Server recieves event
  4. Server fires to every client except the player that shot
  5. Other players see the effect, and the feeling of input lag is gone.
5 Likes

I will try that later. Until then I will seek for other possible solutions

1 Like

That’s really the only way to have viable server-client communication while giving the client instant feedback when they shoot. It’s what almost every top game you see that requires real time action does.

1 Like

Yeah but that method seems a little bit over the top. I will see if there are better alternatives and try all of them and see which one of them is the best.

You were right! It is working like a charm :slight_smile:. But wouldn’t exploiters be able to easily steal my code now? Also isn’t this too much work to do considering I wouldn’t just want to fire energy balls out of my hand but also add abilities to the energy ball such as explosions, kill the player who touches the ball etc…

Exploiters can steal anything that’s replicated or visible to them. Why worry about that? Would you rather botch your codebase and worry about a couple of scumbags who get a kick out of putting others down, or would you rather focus on getting your game out and allowing your audience to enjoy a smooth, lasting and enjoyable experience?

The merit far outweighs the risk. I’d say do it anyway, despite this acknowledgement. There are just some things you can’t avoid and that you have to grit your teeth over. The reward is more satisfying than trying to fight off a few hundred or more exploiters.

Yeah you are right, I agree with you. Even if they steal my code that is fine, it is not like they will steal my whole game, just the abilities and I am fine with that.

Actually it appears that I am still having lag issues :confused:. https://gyazo.com/afe52ae99b45470b2dc8c38e72235190
It gets worse by the way. I followed your method. The feeling of lag is indeed gone but there is still latency.

There’s always latency. The most you can do is make it look like there’s not by having all effects/animations locally rendered.

1 Like