How do I fix these enormous lag spikes in my game?

  1. Try resizing each part to only 1 stud high
  2. Change the BasePart.BottomSurface property to Enum.SurfaceType.Inlet
  3. Change the BasePart.BackSurface, BasePart.FrontSurface, BasePart.LeftSurface, BasePart.RightSurface, and BasePart.TopSurface properties to Enum.SurfaceType.Weld.
  4. Try using UnionOperations to reduce the number of BaseParts.

So what Iā€™m gonna do to counter the problem I stated below is that I will set each item a attribute called bought and every 2 seconds it loops through every dropper and if its not bought itll ignore it and itll be forgotten for the left of itā€™s life!!!

So far I havenā€™t encountered a texturizing tool that can texture unions into studsā€¦

1 Like

Alright guys after some careful cooking (I reached 80F), I think this script should do what I want it to do.

local itemsFolder = script.Parent.Parent
local ss = game.ServerStorage
local function drop(dropperModel, dropType)
	local dropperModel = dropperModel
	local dropPart1 = dropperModel:FindFirstChild("dropPart1")
	local dropPart2 = dropperModel:FindFirstChild("dropPart2")
	local dropPart3 = dropperModel:FindFirstChild("dropPart3")
	local dropPart4 = dropperModel:FindFirstChild("dropPart4")
	local dropValue = dropperModel:GetAttribute("DropValue")
	if dropPart1 then
		local newDrop = ss:WaitForChild(dropType.."Drop")
		newDrop.Parent = dropperModel:FindFirstChild("Drops")
		newDrop.CastShadow = false
		newDrop.CFrame = dropPart1.CFrame
		newDrop:SetAttribute("Value", dropValue)
		newDrop.Name = dropType.."Drop"
		newDrop.Anchored = false
	end
	if dropPart2 then
		local newDrop = ss:WaitForChild(dropType.."Drop")
		newDrop.Parent = dropperModel:FindFirstChild("Drops")
		newDrop.CastShadow = false
		newDrop.CFrame = dropPart1.CFrame
		newDrop:SetAttribute("Value", dropValue)
		newDrop.Name = dropType.."Drop"
		newDrop.Anchored = false
	end
	if dropPart3 then
		local newDrop = ss:WaitForChild(dropType.."Drop")
		newDrop.Parent = dropperModel:FindFirstChild("Drops")
		newDrop.CastShadow = false
		newDrop.CFrame = dropPart1.CFrame
		newDrop:SetAttribute("Value", dropValue)
		newDrop.Name = dropType.."Drop"
		newDrop.Anchored = false
	end
	if dropPart4 then
		local newDrop = ss:WaitForChild(dropType.."Drop")
		newDrop.Parent = dropperModel:FindFirstChild("Drops")
		newDrop.CastShadow = false
		newDrop.CFrame = dropPart1.CFrame
		newDrop:SetAttribute("Value", dropValue)
		newDrop.Name = dropType.."Drop"
		newDrop.Anchored = false
	end
end

while true do
	task.wait(2)
	for num, dropper in itemsFolder:GetChildren() do
		if dropper:HasTag("Dropper") and dropper:GetAttribute("Bought") then
			local dropType = dropper:GetAttribute("DropType")
			drop(dropper, dropType)
		end
	end
end

So basically thereā€™s a function that checks if the dropperModel has dropParts1, 2, 3, or 4, and then itā€™ll generate a new drop from serverStorage based on paramater #2, drop type. The while loop loops through every item you have and if it is Bought and is a Dropper then it will fire the function. Let me know your thoughts on this and if there are some errors or things I could fix to reduce lag even more!

1 Like

Ermmā€¦ what the heck?


Screenshot 2024-07-23 at 3.46.16 PM
This is so goofy

1 Like