How to make a script that works around the part size limit

Getting straight to the point: I’d like to make a fortnite-like storm zone system where a large zone closes in slowly all the way until the entire map is in the storm. The problem is that the part size limit, 2048 prevents a storm like this from being created, since the storm should be larger than that. Ive looked for posts and none of them seem to help.

Ive already found out how to make bigger parts for the middle of the storm (the edges of the storm). Just want to know how I can resize, or fill the inside of the storm.

Any tips? Kinda urgent, so help would be appreciated.

I don’t understand

I got some progress done. I got the storm inside part working. Working on the storm walls now.

2 Likes

Alright. You could of left a more detailed explanation of why you don’t understand.

Alternatively, All I need to know is how to make it so there’s a specific area where the player doesn’t take damage which can be larger than the part size limit, and can be moved and resized dynamically.

You can make bigger parts if you create a large cube in Blender, export it as an obj, and import it as a meshpart with the Import 3D button. Collisions and ZonePlus will work.

1 Like

Is this for me or for you? I don’t have a clear explanation on what this is.

It’s the storm inside I’m working on for you. Once I finish I’ll give you the final result. I already got it working where players in the storm inside take no damage and players outside do, but I need to code the visuals for the walls now.

1 Like

Oh alright. You did more than needed, I thank you for that.

You shouldn’t create 1 storm, you should just subdivide a circle into segments.

1 Like

The purple blocks are just visualizers. I am still working on the borders for the storm.

1 Like

Unfortunately I couldn’t get the borders working properly, it may be possible with SpecialMeshes or some math. But this is all I could do.

  1. Create a Model in Workspace
  2. Name the Model Storm
  3. Set the Storm Model's ModelStreamingMode property to Persistent
  4. Create a Script in ServerScriptService with the following code:
local Workspace = game:GetService("Workspace")
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local stormFolder = Workspace.Storm

local INITIAL_STORM_SIZE = 6144
local STORM_HEIGHT = 128
local STORM_ORIGIN = Vector3.new(0, 0, 0)
local PART_SIZE_LIMIT = 2048
local STORM_MINIMUM_SIZE = 32
local BORDER_THICKNESS = 4
local STORM_SHIRNK_RATE = 8
local HUMANOID_DAMGE = 10
local DAMAGE_DELAY = 1

local damagedHumanoids = {}
local stormSize = Vector3.new(INITIAL_STORM_SIZE, STORM_HEIGHT, INITIAL_STORM_SIZE)

local function createPart(size, position, addTag, transparency)
	local part = Instance.new("Part")
	part.Anchored = true
	part.CanCollide = false
	part.CastShadow = false
	part.Transparency = transparency
	part.Color = Color3.fromRGB(170, 0, 170)
	part.Size = size
	part.Position = position
	part.Parent = stormFolder
	if addTag then
		part.Name = addTag
		part:AddTag(addTag)
	end
	return part
end

local function clearStormParts()
	for _, stormInsidePart in ipairs(CollectionService:GetTagged("StormInsidePart")) do
		stormInsidePart:Destroy()
	end
	for _, stormBorderPart in ipairs(CollectionService:GetTagged("StormBorderPart")) do
		stormBorderPart:Destroy()
	end
end

local function splitStormPart(origin, size)
	local numPartsX = math.ceil(size.X / PART_SIZE_LIMIT)
	local numPartsZ = math.ceil(size.Z / PART_SIZE_LIMIT)

	local partSizeX = size.X / numPartsX
	local partSizeZ = size.Z / numPartsZ

	local offsetX = size.X / 2 - partSizeX / 2
	local offsetZ = size.Z / 2 - partSizeZ / 2

	for i = 1, numPartsX do
		for j = 1, numPartsZ do
			local partPosition = Vector3.new(
				origin.X - offsetX + (i - 1) * partSizeX,
				origin.Y,
				origin.Z - offsetZ + (j - 1) * partSizeZ
			)
			local partSize = Vector3.new(
				math.min(partSizeX, size.X - (i - 1) * partSizeX),
				size.Y,
				math.min(partSizeZ, size.Z - (j - 1) * partSizeZ)
			)
			createPart(partSize, partPosition, "StormInsidePart", 1)
		end
	end
end

local function createStormBorderParts()
	local minX, minY, minZ = math.huge, math.huge, math.huge
	local maxX, maxY, maxZ = -math.huge, -math.huge, -math.huge

	for _, stormInsidePart in ipairs(CollectionService:GetTagged("StormInsidePart")) do
		local partPosition = stormInsidePart.Position
		local partSize = stormInsidePart.Size

		minX = math.min(minX, partPosition.X - partSize.X / 2)
		minY = math.min(minY, partPosition.Y - partSize.Y / 2)
		minZ = math.min(minZ, partPosition.Z - partSize.Z / 2)

		maxX = math.max(maxX, partPosition.X + partSize.X / 2)
		maxY = math.max(maxY, partPosition.Y + partSize.Y / 2)
		maxZ = math.max(maxZ, partPosition.Z + partSize.Z / 2)
	end
	local borderArray = {
		{Position = Vector3.new(BORDER_THICKNESS, maxY - minY, maxZ - minZ), Size = Vector3.new(minX - BORDER_THICKNESS / 2, minY + (maxY - minY) / 2, minZ + (maxZ - minZ) / 2)},
		{Position = Vector3.new(BORDER_THICKNESS, maxY - minY, maxZ - minZ), Size = Vector3.new(maxX + BORDER_THICKNESS / 2, minY + (maxY - minY) / 2, minZ + (maxZ - minZ) / 2)},
		{Position = Vector3.new(maxX - minX, maxY - minY, BORDER_THICKNESS), Size = Vector3.new(minX + (maxX - minX) / 2, minY + (maxY - minY) / 2, minZ - BORDER_THICKNESS / 2)},
		{Position = Vector3.new(maxX - minX, maxY - minY, BORDER_THICKNESS), Size = Vector3.new(minX + (maxX - minX) / 2, minY + (maxY - minY) / 2, maxZ + BORDER_THICKNESS / 2)}
	}
	for _, borderDict in ipairs(borderArray) do
		local borderPart = createPart(borderDict.Position, borderDict.Size, "StormBorderPart", 0)
	end
end

local function damageHumanoids()
	local characters = {}
	local charactersToDamage = {}
	for _, player in ipairs(Players:GetPlayers()) do
		if player.Character and player.Character.PrimaryPart then
			table.insert(characters, player.Character)
			table.insert(charactersToDamage, player.Character)
		end
	end
	local overlapParams = OverlapParams.new()
	overlapParams.FilterDescendantsInstances = characters
	overlapParams.FilterType = Enum.RaycastFilterType.Include
	for _, v in ipairs(Workspace:GetPartBoundsInBox(CFrame.new(STORM_ORIGIN), Vector3.new(stormSize.X, 1024, stormSize.Z), overlapParams)) do
		local character = v.Parent
		if character and table.find(charactersToDamage, character) then
			table.remove(charactersToDamage, table.find(charactersToDamage, character))
		end
	end
	for _, character in ipairs(charactersToDamage) do
		local humanoid = character:FindFirstChildOfClass("Humanoid")
		if humanoid then
			if not damagedHumanoids[humanoid] then damagedHumanoids[humanoid] = 0 end
			if tick() - damagedHumanoids[humanoid] > DAMAGE_DELAY then
				damagedHumanoids[humanoid] = tick()
				humanoid:TakeDamage(HUMANOID_DAMGE)
			end
		end
	end
end

RunService.Heartbeat:Connect(function()
	if stormSize.X >= STORM_MINIMUM_SIZE then
		clearStormParts()
		splitStormPart(STORM_ORIGIN, stormSize)
		createStormBorderParts()
		stormSize -= Vector3.new(STORM_SHIRNK_RATE, 0, STORM_SHIRNK_RATE)
		print(stormSize)
	end
	damageHumanoids()
end)

Further Reading

2 Likes

Can I make the storminsidepart as big as I want? Thats all i need. Thank you for this anyways.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.