When a player equips a knife from the shop, it clones the handle which is weld on the back. The issue is that, when he equips another knife, the handle appears on top of previous handle. Basically, it stacks on the top on previous handles and I don’t want it. Here is my script:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function()
local function wieldKnife()
if player.Character then
local KnifeValue = player:FindFirstChild("EquippedKnife").Value
if KnifeValue ~= "" then
local knife = game.ServerStorage.KnifeHandle:WaitForChild(KnifeValue)
local handle = knife:Clone()
handle.Parent = player.Character
local Weld = Instance.new("ManualWeld")
Weld.Enabled = true
Weld.Part0 = handle
Weld.Part1 = player.Character:WaitForChild("UpperTorso")
Weld.Parent = player.Character
Weld.C0 = CFrame.Angles(math.rad(180), math.rad(90), math.rad(-30))
Weld.C1 = CFrame.new(0,0,0.5)
elseif KnifeValue == "" then
local handleTwo = game.ServerStorage.KnifeHandle.Handle:Clone()
handleTwo.Parent = player.Character
local Weld = Instance.new("ManualWeld")
Weld.Enabled = true
Weld.Part0 = handleTwo
Weld.Part1 = player.Character:WaitForChild("UpperTorso")
Weld.Parent = player.Character
Weld.C0 = CFrame.Angles(math.rad(180), math.rad(90), math.rad(-30))
Weld.C1 = CFrame.new(0,0,0.5)
end
end
end
game.ReplicatedStorage.KnifeWield.OnServerEvent:Connect(wieldKnife)
end)
end)