So I have been trying to find something like this and I found some that's 5 years old but what I need is to touch a block and get a hat put on my head but I some how cant find out how to and this is what I found and it works! But I thought I found it but it was wrong so can you help me with it? |Script|
shirtid = "http://www.roblox.com/asset/?id=751061408" pantsid = "http://www.roblox.com/asset/?id=1134006219" accessoryid = "https://web.roblox.com/catalog/416833190/Tokyokhaos-Lion" script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid")then char = hit.Parent if char:findFirstChild("Shirt") then char.Shirt.ShirtTemplate = shirtid else a = Instance.new("Shirt", char) a.Name = "Shirt" a.ShirtTemplate = shirtid end if char:findFirstChild("Pants") then char.Pants.PantsTemplate = pantsid else b = Instance.new("Pants", char) b.Name = "Pants" b.PantsTemplate = pantsid end if char:findFirstChild("Accesory") then char.Pants.PantsTemplate = pantsid else b = Instance.new("Accessory", char) b.Name = "Accessory" b.HatTemplate = accessorysid end end end)
|Info| The clothing part works its just the hat part the dose not! |Warning!| Anybody can use the fixed script!
Roblox put a new system in place to do this easily.
https://devforum.roblox.com/t/new-api-for-equipping-assets-on-humanoid-player-avatars/233076 https://developer.roblox.com/articles/humanoiddescription-system
You can create or pre-make HumanoidDescriptions and apply them once they touch a part. Make sure you add debounces to the touched event so it doesn't apply it too many times.
Accessories have Handles, like tools. You can add a special mesh inside of the Handle (The Handle HAS to be a part named Handle). and then you can change the special mesh