I am currently facing an issue with network ownership. When you get the ball and shoot it, you are given network ownership of the ball. This caused an issue where players who had horrible ping would shoot the ball and it would lag everywhere and sometimes not even go anywhere at all whilst also making the keeper struggle to save it. I tried to counter this by setting the network ownership to the server 1 second after the player has shot the ball, but this makes the ball stutter and also stops the goal from detecting who scored. what do I do?
local ball = workspace.TestBall
create("Unrecievable",ball,0.6)
ball.CanCollide = true
if Character:FindFirstChild("HasBall") then
Character.HasBall:Destroy()
end
if Character.HumanoidRootPart:FindFirstChild("BallPossession") then
Character.HumanoidRootPart.BallPossession:Destroy()
end
if Character:FindFirstChild("OwnerCircle") then
Character:FindFirstChild("OwnerCircle").Transparency = 1
end
if Character:FindFirstChild("OwnHL") then
Character.OwnHL:Destroy()
end
if Character:FindFirstChild("ShotPowerBuff") then
power += Character.ShotPowerBuff.Amount.Value
end
create("SlowDown",Character,0.1)
create("CantShoot",Character,0.3)
ball.Taken.Value = false
ball:SetNetworkOwner(game.Players:GetPlayerFromCharacter(Character))
game["Run Service"].Heartbeat:Wait()
ball.CFrame = cframe * CFrame.new(0,-1,0)
local force = mousepos * power * 0.85
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Parent = ball
bodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local upwardForce = (power - 60) / 50 * 10
bodyVelocity.Velocity = force + Vector3.new(0, upwardForce, 0)
task.delay(1, function()
ball:SetNetworkOwner(nil)
end)
game.Debris:AddItem(bodyVelocity,0.5)
That’s pretty much caused by SetNetworkOwner being set to a player. The ball’s network is owned by the player, so if the player has issues with the network, the ball would lag too. Even a slight shift in the ping (eg. 100 ms to 130ms) can lag the ball. If SetNetworkOwner is set to the server(which is nil), as long as the server itself does not lag, the ball will not lag.
It’s not possible to mitigate lag entirely, but you can use some smooth animations to the ball when it moves (like TweenService) instead of raw moving (like via Position).
But when I set the network owner to the server, the ball has a delay before it’s fired on the player’s screen. Is there anyway to fix that too? would applying the force on both server and client work?
Maybe you shouldn’t set the network owner at all. If the network owner doesn’t change automatically when the player kicks the ball, then there’s no point to change it to the server again.
If you apply the force on the server, the client will see it. You don’t need to apply the force to the client.
Blockquote
Maybe you shouldn’t set the network owner at all. If the network owner doesn’t change automatically when the player kicks the ball, then there’s no point to change it to the server again.
This would make the network owner the server by default which causes the delay to happen because the server has to replicate the ball physics to the client who kicked it, giving the feeling of a delay and I have no way of suppressing it but only hiding it, which is not conventional
There is no way to completely remove the delay, but I do suggest you remove game["Run Service"].Heartbeat:Wait() and ball:SetNetworkOwner(game.Players:GetPlayerFromCharacter(Character)). I see that they both make the delay longer.
Is there anyway to replicate it like blue lock rivals? They happen to use client network ownership but somehow don’t get the glitch of the ball not moving at all when it is kicked
Using linear velocity has appeared to have solved the ball staying in the place which was the only issue of using the client ownership??? thanks I guess but I wonder why that’s the case