I’m trying to make a script that basically freezes the game. This script will anchor/unanchor every part in the game accordingly. However, doing this will cause a lot of lag (since there are a lot of parts in the game)
Is there any alternative to this, or should I just not do this?
Anchoring all parts in game should not be laggy but un-anchoring will be. Are there parts in the game that are auto anchored so they dont need to be un-anchored and re anchored? or does every part need to be
un-anchored and re anchored?
if every part needs to be un-anchored and re anchored i would suggest not doing this.
There are some parts (like buildings) that stay anchored. I only anchor the parts that were previously not anchored, then I insert them into a table where they then can be unanchored later
for i, v in pairs(workspace:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") then
v.Anchored = true -- can be false if wanted
end
end
some rough code tyoed up, i suppose this could work for ALL objects
edit:
ok scratch that, make a table add names in it you wanna keep anchored or not, check if the item name is in the table (table.find(tbl, name)), if so then anchor or unanchor them
This is what I’m currently doing, which just makes it lag a lot when you unanchor. I was thinking of a substitute to get the anchor effect but I currently know none
Yeah, I thought of setting gravity to 0 (it didn’t work obviously) and other stuff but I don’t really have much knowledge of the physics system in Roblox so nothing I’ve tried worked
local Workspace = workspace
local function AnchoredToggle(Boolean)
local BaseParts = {}
for _, Descendant in ipairs(Workspace:GetDescendants()) do
if Descendant:IsA("BasePart") then table.insert(BaseParts, Descendant) end
end
for Index, BasePart in ipairs(BaseParts) do
if Index % 100 == 0 then task.wait() end
BasePart.Anchored = Boolean
end
end