(Skip to 0:34) I use server physics, so that may be the problem, but Network Ownership doesn’t seem like a good idea because of the lag when switching owners. Help would be appreciated. Thank you!
Also here is a snippet from my local script:
uis.JumpRequest:Connect(function()
if char.Humanoid.FloorMaterial ~= Enum.Material.Air and char:GetAttribute("Mode") == "Block" and blockstarted == false then
blockstarted = true
local blockanim = char.Humanoid.Animator:LoadAnimation(script.Block)
local md = char.Humanoid.MoveDirection
local lastmd = md
local vf = Instance.new("VectorForce")
local att = Instance.new("Attachment")
att.Parent = char.HumanoidRootPart
vf.Attachment0 = att
vf.Parent = char.HumanoidRootPart
vf.RelativeTo = Enum.ActuatorRelativeTo.World
vf.ApplyAtCenterOfMass = true
vf.Force = lastmd * 2000
game.Debris:AddItem(vf, 1.5)
game.Debris:AddItem(att, 1.5)
char.Humanoid.WalkSpeed = 0
blockanim:Play()
if char:GetAttribute("Build") == "Tall" then
local tallhb = game.ReplicatedStorage:WaitForChild("HitBoxes").Tallhb:Clone()
tallhb.Parent = char
tallhb.Position = char.HumanoidRootPart.Position
tallhb.WeldConstraint.Part0 = char.HumanoidRootPart
game.Debris:AddItem(tallhb, 1.3)
local olp = OverlapParams.new()
olp.CollisionGroup = "Ball"
local balldetected = false
while tallhb.Parent ~= nil do
if balldetected == true then
break
end
for i,v in pairs(workspace:GetPartsInPart(tallhb, olp)) do
if v.Name == "GameBall" and v:GetAttribute("Active") then
remmodule:FireServer("Block", v)
balldetected = true
end
end
task.wait()
end
else
local shorthb = game.ReplicatedStorage:WaitForChild("HitBoxes").Shorthb:Clone()
shorthb.Parent = char
shorthb.Position = char.HumanoidRootPart.Position
shorthb.WeldConstraint.Part0 = char.HumanoidRootPart
game.Debris:AddItem(shorthb, 1.3)
local olp = OverlapParams.new()
olp.CollisionGroup = "Ball"
local balldetected = false
while shorthb.Parent ~= nil do
if balldetected == true then
break
end
for i,v in pairs(workspace:GetPartsInPart(shorthb, olp)) do
if v.Name == "GameBall" and v:GetAttribute("Active") then
remmodule:FireServer("Block", v)
balldetected = true
end
end
task.wait()
end
end
char.Humanoid.WalkSpeed = 16
blockstarted = false
end
end)
Also I forgot to mention that I am using EasyNetwork(a Remote module) instead of normal remote events. I`m not sure if that affects much, but I’ll just add it here just in case. I also use a module instead of just doing everything in a server script.
Ping, you either accept it or fight it, as we all try to in gamedev.
It’s the reason sometimes you get shot through walls in the games, knifed over a kilometer away in MM2. There’s more to it.
solutions
counter it with block events
as soon as your player blocks, on his screen a ball he sees, he alters the ball immediately, no matter where on the screen of other players it is. that has to be synced via custom code, replication. it solves your issue and doesn’t require much effort. i’d start with that
replication
roblox replication is 20 frames per seconds with half a second buffer. that means each movement you see is half a second behind + ping. a lot of people are doing their own custom projects with custom character replication which gives more fps and faster reaction, yet that might be a bit of an overkill
conclusion
ping will always matter and there is unfortunately no way to fully fix this right now, unless we get quantum computers with neuralink, like, asap.
key note: prioritize player input over any physics/gameplay as such games are always competitive, and that means they are active and engaging. and that is great for a roblox game.
Replication is the act of updating states from another client using the server as a transmitter.
Most simple example of this is:
local Players = game:GetService("Players")
local r = Instance.new("RemoteEvent")
r.OnServerEvent:Connect(function(player: Player, data: any?)
if not data then
return
end
for _, other_player: Player in Players:GetPlayers() do
if other_player ~= player then
-- :: call the update on another player.
-- :: for example, i'd love to know which plr sent it
-- :: as well as replicating the data!
r:FireClient(other_player, player, data)
end
end
end
This is just for explanation purposes.
Use buffer libraries such as ByteNet. They are optimized and compress your data.
Netcode on ROBLOX 90% of times is the most important part of the solution, the game.
A bit, server is used as a proxy while you solve the physics locally for each player. That is techically the best solution as it would be smoother and more defined for each client, no matter where the ball on their screen is. Yet, it sacrifices simplicity and may cause desync.
This is the solution if you are willing to go for creating the “custom physics” and battling desyncs.
Let’s start simple, of course.
Send client block collision CFrame through RemoteEvent on the ball’s touch.
Server sets the ball to that CFrame and adds velocity to it.
And it works.
Not perfect. Ball will ignore player on his screen due to ping, yet, eventually, the ball will be blocked and the issue is…
Solved? I guess that’s for you to decide on how much you’re willing to go into this. I’m gonna log off for today, thanks for listening to my TED talk.
Uhh, I have no idea which freezing you are talking about, can’t see your code nor any screenshots and haven’t yet learned how to read thoughts with the exact precision. Describe your issue more in depth I guess?