Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

TRYING to weld a model to a players character, anchoring problems?

Ok so im making a mask somewhat so when the player touches it they get the mask on their head/face but for some reason it isnt even welding properly, i've put anchored == false yet it still welds my character on to the floating mask and some parts of the mask just fall down, it gives me this message "anchored is not a valid member of script" even though im clearly avoiding it by singling out the MeshParts and Parts of the mask. SO AT THE SAME TIME ITS ANCHORING MY CHARACTER TO A PART THATS UNANCHORED?


local Head = script.Parent
local Touch = script.Parent.nose
    Touch.Touched:Connect(function(p)
    local player = game.Players:GetPlayerFromCharacter(p.Parent)
    if player then
    if not player.Character:FindFirstChild("sd.bbb :yes:") then
    local clone = Head:Clone()
    clone.Parent = player.Character
    clone:SetPrimaryPartCFrame(player.Character.Head.CFrame)
    clone.Name = "sd.bbb :yes:"
    local w = Instance.new("Weld")
    w.Part0 = clone.Root
			    w.Part1 = p.Parent.Head
			
			    w.Parent = clone.Root
			w.C0 = CFrame.new(0,0,1)
			
			 for _,v in pairs(clone:GetChildren()) do
				if v.ClassName == "MeshPart" or "Part" then
					
				
				    v.Anchored = false
				end
				end
    end
    end
    end)

1 answer

if v.ClassName == "MeshPart" or "Part" you made a mistake here. In programming this will be taken as two separate statemements. if v.ClassName == "MeshPart" and if "Part". You see what's happening. So it will always pass through. You need to do it like so

if v.ClassName == "MeshPart" or v.ClassName == "Part" then

I don't know if this will fix the problem because I'm not very experienced in welding.

This discussion is preserved as it was. New answers, comments, and votes are closed.