I know you technically aren't supposed to request scripts here, but this seems very simple. I'm just really inexperienced at scripting when it comes to tools.
I am basically trying to redesign the old clone tool from 2006. I made multiple-part crates that are all grouped in separate models that are supposed to be unanchored and weld to other parts. This script only clones and moves one part at a time, not the entire crate. Is there a way to easily fix this script so it clones the entire model and not just one part in it?
debounce = false
local vPlayer = game.Players.LocalPlayer
local SBox = Instance.new("SelectionBox")
local Tool = script.Parent;
local Select
local Orig
local Dragger
function onButton1Down(mouse)
local Target = mouse.Target
local Sound = Instance.new("Sound")-- The "ding" sound
Sound.SoundId = "rbxasset://sounds\\electronicpingshort.wav"
Sound.Name = "PewPew"
Sound.Parent = Tool
if Target and Target:IsA("BasePart") and not Target.Locked then
if debounce == false then
debounce = true
Orig = Target
Select = Orig:clone()
Select.Parent = game.Workspace
Select.Position = Orig.Position + Vector3.new(0, 0.4, 0)
Dragger = Instance.new("Dragger")
pcall(function() Dragger:MouseDown(Select, Vector3.new(0, 0, 0), {Select}) end)
SBox.Adornee = Select
Sound:Play()
wait(1.5)
mouse.Icon = "rbxasset://textures\\DragCursor.png"
debounce = false
end
end
end
function onButton1Up(mouse)
if Dragger then
Orig = nil
pcall(function() Dragger:MouseUp() end)
Select = nil
SBox.Adornee = nil
Dragger = nil
mouse.Icon = "rbxasset://textures\\CloneOverCursor.png"
end
end
function onMouseMove(mouse)
if Dragger then
mouse.Icon = "rbxasset://textures\\GrabRotateCursor.png"
pcall(function() Dragger:MouseMove(mouse.UnitRay) end)
else
local Target = mouse.Target
if Target and Target:IsA("BasePart") and not Target.Locked then
mouse.Icon = "rbxasset://textures\\CloneOverCursor.png"
else
mouse.Icon = "rbxasset://textures\\CloneCursor.png"
end
end
end
function onKeyDown(key)
if Dragger then
key = key:lower()
if key == 'r' then
Dragger:AxisRotate(Enum.Axis.Y)
elseif key == 't' then
Dragger:AxisRotate(Enum.Axis.Z)
end
end
end
function onEquippedLocal(mouse)
SBox.Color = BrickColor.new("Cyan")
SBox.Parent = vPlayer.PlayerGui
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Button1Up:connect(function() onButton1Up(mouse) end)
mouse.Move:connect(function() onMouseMove(mouse) end)
mouse.KeyDown:connect(onKeyDown)
end
function onUnequippedLocal(mouse)
if Tool:findFirstChild("PewPew") then
Tool.PewPew:remove()
end
if Dragger then
Orig = nil
pcall(function() Dragger:MouseUp() end)
Select = nil
SBox.Adornee = nil
Dragger = nil
end
end
Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)
I obviously didn't type most of this script, so some parts may seem outdated.
