optimize this roblox code local parts = workspace.Flag.Parts local players =…
- User
optimize this roblox code local parts = workspace.Flag.Parts local players = game:GetService('Players') local client = players.LocalPlayer
local key for i,v in pairs(getgc()) do if (type(v) == 'function' and islclosure(v)) then local upvalues = debug.getupvalues(v)
if (#upvalues == 4 and type(upvalues[1]) == 'function' and debug.getinfo(upvalues[1]).name == 'getRaycastResult') then key = upvalues[4] end end if (key) then break endend
local function get_num(part) return tonumber(part.NumberGui.TextLabel.Text) end
local function is_hidden(part) return (get_num(part) == 0) end
local function get_radius(part) local around = {}
local origin = part.Position + Vector3.new(0, 5, 0) local rays = { Ray.new(origin + Vector3.new(0, 0, -3), Vector3.new(0, -5, 0)), Ray.new(origin + Vector3.new(0, 0, 3), Vector3.new(0, -5, 0)), Ray.new(origin + Vector3.new(3, 0, 0), Vector3.new(0, -5, 0)), Ray.new(origin + Vector3.new(-3, 0, 0), Vector3.new(0, -5, 0)), Ray.new(origin + Vector3.new(3, 0, -3), Vector3.new(0, -5, 0)), Ray.new(origin + Vector3.new(3, 0, 3), Vector3.new(0, -5, 0)), Ray.new(origin + Vector3.new(-3, 0, -3), Vector3.new(0, -5, 0)), Ray.new(origin + Vector3.new(-3, 0, 3), Vector3.new(0, -5, 0)) } for i,v in pairs(rays) do local test = workspace:FindPartOnRayWithIgnoreList(v, {client.Character}) if (test ~= nil) then around[i] = test end end return aroundend
local function get_hidden_parts(tab) local amt = 0; local parts = {}
for i,v in pairs(tab) do if (is_hidden(v)) then amt = amt + 1 table.insert(parts, v) end end return amt, partsend
local function get_flags(part) local around = {}
local origin = part.Position + Vector3.new(0, 11, 0) local rays = { Ray.new(origin + Vector3.new(0, 0, -5), Vector3.new(0, -11, 0)), Ray.new(origin + Vector3.new(0, 0, 5), Vector3.new(0, -11, 0)), Ray.new(origin + Vector3.new(5, 0, 0), Vector3.new(0, -11, 0)), Ray.new(origin + Vector3.new(-5, 0, 0), Vector3.new(0, -11, 0)), Ray.new(origin + Vector3.new(5, 0, -5), Vector3.new(0, -11, 0)), Ray.new(origin + Vector3.new(5, 0, 5), Vector3.new(0, -11, 0)), Ray.new(origin + Vector3.new(-5, 0, -5), Vector3.new(0, -11, 0)), Ray.new(origin + Vector3.new(-5, 0, 5), Vector3.new(0, -11, 0)) } for i,v in pairs(rays) do local test = workspace:FindPartOnRayWithIgnoreList(v, {client.Character}) if (test ~= nil and test.Parent.Name:find('Flag')) then table.insert(around, test) end end return aroundend
local function apply_flags(target, num, parts) if (num == target) then for i = 1, target do local part = parts[i]
if (not part:FindFirstChildWhichIsA('Model')) then game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("FlagEvents"):WaitForChild("PlaceFlag"):FireServer(part, key, true) end end end - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.