#How do i prevent this from happening?

1 messages · Page 1 of 1 (latest)

lost depot
#

Whenever i press e or unequip wolfenchan gun the torso acessories/morph comes off but helmets dont. i tried many ways and it doesnt work

#

Here are scripts

serene patrolBOT
#

studio** You are now Level 1! **studio

lost depot
#

Welder

local create = require(game:GetService("ReplicatedStorage"):WaitForChild("LoadLibrary"):WaitForChild("RbxUtility")).Create

function weldObject(x, y)
local cf = CFrame.new(x.Position)
local c0 = x.CFrame:toObjectSpace(cf)
local c1 = y.CFrame:toObjectSpace(cf)
create("Weld"){
Part0 = x,
Part1 = y,
C0 = c0,
C1 = c1,
Parent = x,
}
end

function combineParts(object)
if script.Parent:FindFirstChild("Handle") then
if object:IsA("BasePart") then
weldObject(script.Parent.Handle, object)
object.Anchored = false
else
table.foreach(object:GetChildren(), function(i, c)
combineParts(c)
end)
end
else
print("Handle is nil!")
end
end

combineParts(script.Parent)

script.Disabled = true

modest flicker
#

try ts

#

local tool = script.Parent

-- function to clear morph + helmets
local function clearMorphs(character)
if not character then return end

-- Remove torso morph parts (custom parts)
for _, part in ipairs(character:GetChildren()) do
    if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
        if part:FindFirstChild("WolfenchanMorphTag") then -- optional tag you add to morph parts
            part:Destroy()
        end
    end
end

-- Remove accessories (like helmets)
for _, acc in ipairs(character:GetChildren()) do
    if acc:IsA("Accessory") then
        acc:Destroy()
    end
end

end

tool.Unequipped:Connect(function()
local char = tool.Parent
if char and char:FindFirstChild("Humanoid") then
clearMorphs(char)
end
end)

-- if you also use "E" to unequip
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E then
local char = tool.Parent
if char and char:FindFirstChild("Humanoid") then
clearMorphs(char)
end
end
end)

#

im new in scripting im not sure it will work

modest flicker
#

its a accesorry or a tools ?

#

( im french so my language is not good... )

lost depot
#

except for helmet

#

i tought it was problem with accesory so i switched it out but same was repeating for everything

#

so its tool problem

#

probably

modest flicker
#

kk

serene patrolBOT
#

studio** You are now Level 2! **studio

modest flicker
#

script :

#

local tool = script.Parent
local morphFolder = tool:FindFirstChild("MorphParts") -- Folder with torso/armor parts

-- Tag used to identify morph parts
local TAG_NAME = "WolfenchanMorph"

-- Equip handler
tool.Equipped:Connect(function()
local char = tool.Parent
if not char or not morphFolder then return end

-- Clone morph parts into character
for _, part in ipairs(morphFolder:GetChildren()) do
    if part:IsA("BasePart") or part:IsA("MeshPart") then
        local clone = part:Clone()
        clone.Name = TAG_NAME
        clone.Anchored = false
        clone.CanCollide = false
        clone.Parent = char

        -- Weld to torso
        local hrp = char:FindFirstChild("HumanoidRootPart")
        if hrp then
            local weld = Instance.new("WeldConstraint")
            weld.Part0 = hrp
            weld.Part1 = clone
            weld.Parent = hrp
        end
    end
end

print("Wolfenchan morph equipped!")

end)

-- Unequip handler
tool.Unequipped:Connect(function()
local char = tool.Parent
if not char then return end

-- Remove only morph parts we created (don’t touch accessories)
for _, obj in ipairs(char:GetChildren()) do
    if obj:IsA("BasePart") or obj:IsA("MeshPart") then
        if obj.Name == TAG_NAME then
            obj:Destroy()
        end
    end
end

print("Wolfenchan morph removed!")

end)

lost depot
#

alr

modest flicker
#

WolfenchanGun (Tool)
├─ Handle (Part)
├─ MorphParts (Folder) ← put your torso/armor parts inside here
└─ LocalScript (the script above)

lost depot
#

do i make new script or put it in weld

modest flicker
#

You should make a new script, not put it in your old weld script.

lost depot
#

doesnt work

#

well ty for help

modest flicker
lost depot
#

wolfenchan is bit outdated system so yea not the least laggy one

surreal rampart
#

whats the helmet even?