-
What do you want to achieve? I’m trying to get clones function working. More like it’s selection problem. And you know F3X Tool is kind of outdated.
-
What is the issue? When I clicked clone. It does deselected the part. It’s not supposed to do that. It’s really annoying.
https://gyazo.com/3c48d4e16fef4a8b125da5e5fed5b075
-- Selection
function CloneSelection()
-- Clones selected parts
-- Make sure that there are items in the selection
if #Selection.Items == 0 then
return;
end;
-- Send the cloning request to the server
local Clones = SyncAPI:Invoke('Clone', Selection.Items, GetHighestParent(Selection.Items))
-- Put together the history record
local HistoryRecord = {
Clones = Clones;
Unapply = function (HistoryRecord)
-- Reverts this change
-- Deselect the clones
Selection.Remove(HistoryRecord.Clones, false);
-- Remove the clones
SyncAPI:Invoke('Remove', HistoryRecord.Clones);
end;
Apply = function (HistoryRecord)
-- Reapplies this change
-- Restore the clones
SyncAPI:Invoke('UndoRemove', HistoryRecord.Clones);
end;
};
-- Register the history record
History.Add(HistoryRecord);
-- Select the clones
Selection.Replace(Clones);
-- Flash the outlines of the new parts
coroutine.wrap(Selection.FlashOutlines)();
end;
['Clone'] = function (Items, Parent)
-- Clones the given items
-- Validate arguments
assert(type(Items) == 'table', 'Invalid items')
assert(typeof(Parent) == 'Instance', 'Invalid parent')
assert(Security.IsLocationAllowed(Parent, Player), 'Permission denied for client')
-- Check if items modifiable
if not CanModifyItems(Items) then
return {}
end
-- Check if parts intruding into private areas
local Parts = GetPartsFromSelection(Items)
if Security.ArePartsViolatingAreas(Parts, Player, false) then
return {}
end
local Clones = {}
-- Clone items
for _, Item in pairs(Items) do
local Clone = Item:Clone()
Clone.Parent = Parent
-- Register the clone
table.insert(Clones, Clone)
CreatedInstances[Item] = Item
end
-- Return the clones
return Clones
end;
function Selection.Replace(Items, RegisterHistory)
-- Replaces the current selection with the given new items
-- Save old selection reference for history
local OldSelection = Selection.Items;
-- Find new items
local NewItems = {}
for _, Item in ipairs(Items) do
if not Selection.ItemIndex[Item] then
table.insert(NewItems, Item)
end
end
-- Find removing items
local RemovingItems = {}
local NewItemIndex = Support.FlipTable(Items)
for _, Item in ipairs(Selection.Items) do
if not NewItemIndex[Item] then
table.insert(RemovingItems, Item)
end
end
-- Update selection
if #RemovingItems > 0 then
Selection.Remove(RemovingItems, false)
end
if #NewItems > 0 then
Selection.Add(NewItems, false)
end
-- Create a history record for this selection change, if requested
if RegisterHistory then
TrackSelectionChange(OldSelection);
end;
end;