I’ve got a mine system, where when you break blocks, it creates new blocks around as needed. Having looked at other games with similar systems, they all just do block breaking on the server. While this does solve any issues of the block being destroyed before the other blocks are created, it leads to slow reaction times, and in these games it can take me 1-2 full seconds after I’ve ‘mined’ the block, for it to actually disappear. I wanted to destroy it on the client, so the client destroys it, while the server is also destroying it on server + creating blocks. However, this leads to you falling through the world, as the block is destroyed instantly, but the server hasn’t had time to generate new blocks.
DestroyBlock:FireServer(self.CurrentBlock)
-- Do visuals of entity
CreateEntity:Fire(
self.CurrentBlock:GetAttribute("Id"),
self.CurrentBlock.Position
)
if self.CurrentBlock:IsDescendantOf(Mine.Blocks) then -- Mine block, need to create blocks
CreateMineBlock:Invoke(self.CurrentBlock)
end
self.CurrentBlock:Destroy()
On CreateMineBlock.OnInvoke
local function BlockRemoved(block)
local BlockPosition = block.Position
for _, facePosition in pairs(POSITIONS) do
local NewPosition = BlockPosition + facePosition
local RoundedY = math.floor(NewPosition.Y * 10) / 10
local Position = Vector3.new(NewPosition.X, RoundedY, NewPosition.Z)
if Position.Y > 0.5 then continue end -- Can't go above Y = 0
-- Top levels
if (Position.X < TOP_X.X or Position.X > TOP_X.Y) and Position.Y > TOP_MIN then continue end -- Can't go outside these bounds
if (Position.Z < TOP_Z.X or Position.Z > TOP_Z.Y) and Position.Y > TOP_MIN then continue end -- Can't go outside these bounds
-- Bottom levels
if (Position.X < BOTTOM_X.X or Position.X > BOTTOM_X.Y) and Position.Y > BOTTOM_MIN then continue end -- Can't go outside these bounds
if (Position.Z < BOTTOM_Z.X or Position.Z > BOTTOM_Z.Y) and Position.Y > BOTTOM_MIN then continue end -- Can't go outside these bounds
local PreviouslyGenerated = false
for _, generated in pairs(Mine.Blocks:GetChildren()) do
if generated.Position == Position then -- Already generated
PreviouslyGenerated = true
break
end
end
if PreviouslyGenerated then continue end -- Position already generated
CreateBlock(Position)
end
return true
end
So the above will create temporary blocks on the client, while the server has time to place the real blocks
So, how can I successfully have the block destroyed, and create some ‘temp’ blocks on the client, while the server has time to create the real blocks? Or am I overthinking it, and should just stick with the latency 