I've been trying to replicate this script, just in my own version, but I can't seem to do it. Probably because of my lack of understanding of the script. What the script does is it puts a linked sword on your back when you unequip it. Thanks in advance!
handle = nil
function onUnequipped()
if script.Parent.Parent == workspace or script.Parent.Parent.className ~= "Backpack" then
if handle ~= nil then
handle:remove()
end
return
end
local char = script.Parent.Parent.Parent.Character
if char ~= nil then
local torso = char:findFirstChild("Torso")
local tool = char:findFirstChild(script.Parent.Name)
if torso ~= nil and tool == nil then
handle = script.Parent.Handle:clone()
handle.CanCollide = false
handle.Name = script.Parent.Name
handle.Parent = char
local weld = Instance.new("Weld")
weld.Name = "BackWeld"
weld.Part0 = torso
weld.Part1 = handle
weld.C0 = CFrame.new(0,0,1.1)
weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(90),math.rad(30),0)
weld.Parent = handle
elseif torso ~= nil and tool ~= nil then
if tool.className == "Part" then
handle = tool
tool.Transparency = script.Parent.Handle.Transparency
end
end
end
end
script.Parent.Unequipped:connect(onUnequipped)
function onEquipped()
if handle ~= nil then
handle.Transparency = 1
end
end
script.Parent.Equipped:connect(onEquipped)
|