PasteRegion does not work on the client

  1. In my game, I have pre-build terrain with parts that acts as a region3 to use Terrain:CopyRegion() on then all the terrain is cleared. I want to allow clients to load these chunks in as they load in a different level/hub world. I tested it on the server and I got what I wanted to achieve, but the TerrainRegion data didn’t replicate to the client when using PasteRegion() After some research, I assume that using CopyRegion on the server then having the client paste it wouldn’t work, but then I saw another post saying it does replicate like that. I played it safe and just made the client use CopyRegion, clear the terrain and put the TerrainRegions in a folder in ReplicatedStorage. Alas, it did not work still. Documentation on Terrain functions are not very well written and I am stumped on what’s wrong with my code.

Notes:

  • I had replication issues before in a different game by turning off CharacterAutoLoads and i don’t know if thats affecting me again with this game
local module = {}
local terrain=game:GetService("Workspace"):WaitForChild("Terrain")

local HS=game:GetService("HttpService")


module.Region3FromPart = function(Part)
	local min =  Part.Position - (0.5 * Part.Size)
	local max = Part.Position + (0.5 * Part.Size)
	
	return Region3int16.new(
		Vector3int16.new(min.X, min.Y, min.Z)/4,
		Vector3int16.new(max.X, max.Y, max.Z)/4
	)
end

function module:SetupTerrainClient()
	for i,v in game.ReplicatedStorage:WaitForChild("Client"):WaitForChild("TerrainStorage"):GetChildren() do
	for _,w in v:GetChildren() do
		local terrainCapture=terrain:CopyRegion(self.Region3FromPart(w))
		terrainCapture.Parent=game.ReplicatedStorage:WaitForChild("Client"):WaitForChild("TerrainStorage")
		terrainCapture.Name=v.Name
		local min=w.Position - (0.5 * w.Size)
		terrainCapture:SetAttribute("Corner", Vector3.new(min.X, min.Y, min.Z))
		v:Destroy()
	end
	end
end


function module:SetupRooms()
	local Rooms=game.ServerStorage.Files.Server.Rooms
	
	for i,v in Rooms:GetChildren() do
		local N=v.TerrainNodes
		N.Name=v.Name
		N.Parent=game.ReplicatedStorage:WaitForChild("Client"):WaitForChild("TerrainStorage")
		local val=Instance.new("StringValue", v.Data)
		val.Name="InitName"
		val.Value=v.Name
	end
	
end

function module:LoadRoom(RoomData)
	local GetRoom=game.ReplicatedStorage.Client.Network.Events.GetRoomData:InvokeServer(RoomData)
	terrain:Clear()
	local TerrainData=game.ReplicatedStorage:WaitForChild("Client"):WaitForChild("TerrainStorage"):WaitForChild(GetRoom.Data.InitName.Value)
	local rawVector=TerrainData:GetAttribute("Corner")
	terrain:PasteRegion(TerrainData, Vector3int16.new(rawVector.X, rawVector.Y, rawVector.Z)/4, false)
	GetRoom.Build.Parent=workspace.Stuff
	
end

return module