What do you want to achieve?
I want my katana put on hip
What is the issue?
It doesn’t work out
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I trued looking on dev forum an yt but no results
I parent the katana inside of StarterCharacterScripts because when I resetted character, the attack system will not work
ERROR: Attempt to index nil with Parent, Line 28
if script.Parent.Parent.Name == "Backpack" then
local char = script.Parent.Parent.Parent.Character
if char then
local UpperTorso = char:FindFirstChild("Torso")
local Weapon = char:FindFirstChild(script.Parent.Name)
if UpperTorso and not Weapon then
local weaponOnLeg = Instance.new("Model")
weaponOnLeg.Name = script.Parent.Name
weaponOnLeg.Parent = char
Handle = script.Parent.Handle:Clone()
Handle.Name = "Handle"
Handle.Parent = weaponOnLeg
local legWeld = Instance.new("Weld")
legWeld.Name = "WeldOnLeg"
legWeld.Part0 = UpperTorso
legWeld.Part1 = Handle
legWeld.C0 = CFrame.new(-1, -1.42,0.5) -- 1, -1.42,0.5
legWeld.C0 = legWeld.C0 * CFrame.fromEulerAnglesYXZ(math.rad(150), math.rad(-180), -20.5)
legWeld.Parent = Handle
end
end
else
if Handle.Parent then
Handle.Parent:Destroy()
end
end
end
while task.wait() do
local Handle = script.Parent.Handle:Clone()
if script.Parent.Parent.Name == "Backpack" then
local char = script.Parent.Parent.Parent.Character
if char then
local UpperTorso = char:FindFirstChild("Torso")
local Weapon = char:FindFirstChild(script.Parent.Name)
if UpperTorso and not Weapon then
local weaponOnLeg = Instance.new("Model")
weaponOnLeg.Name = "Model"
weaponOnLeg.Parent = char
Handle.Name = "Handle"
Handle.Parent = weaponOnLeg
local legWeld = Instance.new("Weld")
legWeld.Name = "WeldOnLeg"
legWeld.Part0 = UpperTorso
legWeld.Part1 = Handle
legWeld.C0 = CFrame.new(-1, -1.42,0.5) -- 1, -1.42,0.5
legWeld.C0 = legWeld.C0 * CFrame.fromEulerAnglesYXZ(math.rad(150), math.rad(-180), -20.5)
legWeld.Parent = Handle
end
end
else
if Handle.Parent then
Handle.Parent:Destroy()
end
end
end
Also sorry for wasting your time man im really really sorry
Handle = nil
function onUnequipped()
if script.Parent.Parent == workspace or script.Parent.Parent.className ~= "Backpack" then
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
local model = Instance.new("Model")
model.Name = script.Parent.Name
model.Parent = char
handle = script.Parent.Handle:clone()
handle.CanCollide = false
handle.Name = script.Parent.Name
handle.Parent = model
local weld = Instance.new("Weld")
weld.Name = "BackWeld"
weld.Part0 = torso
weld.Part1 = handle
weld.C0 = CFrame.new(-1, -1.42,0.5)
weld.C0 = weld.C0 * CFrame.fromEulerAnglesYXZ(math.rad(150), math.rad(-180), -20.5)
weld.Parent = handle
end
end
end
script.Parent.Unequipped:connect(onUnequipped)
function onEquipped()
if handle ~= nil then
handle.Parent:remove()
end
end
script.Parent.Equipped:connect(onEquipped)