I have 2 different copies of hats inside of game.ReplicatedStroage.Hats.M > Hat1 and Hat2 are inside it, I would like the script to put a hat on, but using a Value of script.Parent.Hat
So player touches the brick and then he gets the Shirt, Pants, Face, but also a Hat, the same way Shirt and Pants are put on...
I'm trying to achieve a Character Customization system which could be easily edited, that's why I need it all in StringValues. I'm planning to add buttons which would change the Shirt/Pants/Face/Hat of the humanoid, and then when a Player steps on it, they will get the same look. - I would be extremely thankful if anyone of you has a model of this and could share it with me, or could guide me through an easier way of doing this.
I can provide the model: http://www.roblox.com/Model-item?id=237741478
I can't really explain it any better, please ask questions :)
debouce = false local shirt = script.Parent.Shirt local pants = script.Parent.Pants local face = script.Parent.Face local hat = script.Parent.Hat function onTouched(hit) if debouce == false then local h= hit.Parent:findFirstChild("Humanoid") if h~=nil then debouce = true wait(0.1) script.Parent.BrickColor = BrickColor.new("Black") local RP=hit.Parent:GetChildren() for i=1,#RP do if RP[i].className=="Pants" then RP[i]:remove() end end local RS=hit.Parent:GetChildren() for i=1,#RS do if RS[i].className=="Shirt" then RS[i]:remove() end end local RH=hit.Parent:GetChildren() for i=1,#RH do if RH[i].className=="Hat" then RH[i]:remove() end end local P = Instance.new("Pants") P.Parent = hit.Parent P.PantsTemplate = pants.Value local S = Instance.new("Shirt") S.Parent = hit.Parent S.ShirtTemplate = shirt.Value local F = hit.Parent.Head.face F.Texture = face.Value wait(2) script.Parent.BrickColor = BrickColor.new("Bright blue") debouce = false end end end script.Parent.Touched:connect(onTouched)
This is just a script inside of a part.
debounce = false script.Parent.Touched:connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then -- I use FIndFirstChild() to prevent Errors if debounce == false then debounce = true local Copy = game.ReplicatedStorage:FindFirstChild("Hat1"):Clone() local Char = Hit.Parent -- This is the Character(Model that holds all parts) local player = game.Players:GetPlayerFromCharacter(Char) -- So we know WHO to give the Hat Copy.Parent = player.Character wait(3) debounce = false end end end)
I used a debounce so you will not get the hat spammed inside of your character. Obviously above, I used the Touched function. I also used GetPlayerFromCharacter so I will know who it is that touched the part and who it is that will receive the hat. If you need more information on this script, then just comment on this Answer.
Plus 1 and Accept if this helped