Alright, So I'm extremely new to scripting, Learning obviously. I found a tutorial on how script a NPC / Model onto someone, but every time I go to try get clothing on it says,
touch is not a valid member of part
Here is the code
script.Parent.touch:connect(function(hit) if (hit.Parent:FindFirstChild("Humanoid"))then --local plr = game.players:FindFirstChild(hit.Parent.Name) local plrPants = hit.Parent:FindFirstChild("Pants") if (plrPants) then plrPants:remove() end local plrShirt = hit.Parent:FindFirstChild("Shirt") if (plrShirt) then plrShirt:remove() end local newClothingPants =script.Parent.Parent.NPC.Pants:Clone() local newClothingShirt =script.Parent.Parent.NPC.Shirt:Clone() newClothingPants.Parent = hit.Parent newClothingShirt.Parent = hit.Parent end end)
Any help would be appreciated
There is no event called "touch"
, it is called "Touched!"
The proper code would be:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")then --local plr = game.players:FindFirstChild(hit.Parent.Name) local plrPants = hit.Parent:FindFirstChild("Pants") if (plrPants) then plrPants:remove() end local plrShirt = hit.Parent:FindFirstChild("Shirt") if (plrShirt) then plrShirt:remove() end local newClothingPants =script.Parent.Parent.NPC.Pants:Clone() local newClothingShirt =script.Parent.Parent.NPC.Shirt:Clone() newClothingPants.Parent = hit.Parent newClothingShirt.Parent = hit.Parent end)
A simple typo my friend, accept my answer if you want, please. Also note that :connect
is deprecated, use :Connect
, and remove()
is also deprecated, but keep that if you like. And it is also end)
, not end
, because you are closing that (