So, I’m creating a character creation area that uses that basic old technique that is placing wearable hats on the ground.
The script I’m using to make them clone and so the person who touched wears them is the one below:
debounce = true
function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
h = Instance.new("Hat")
p = Instance.new("Part")
h.Name = "yourhat"
p.Parent = h
p.Position = hit.Parent:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(0, 0.1, 0)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentPos = Vector3.new(The AttachmentPos here)
wait(5)
debounce = true
end
end
script.Parent.Touched:connect(onTouched)
It works for some hairs, but for others, it just sends the player to where the accessory is and doesn’t clone it at all. Here’s the screenshots:
Can anyone help me on how I make them become wearable like the other ones?
I honesly don’t know what to do…
The accessories are anchored, which means that when they are cloned the accessory can’t move position and so the character has to move to the hat. Unanchoring them should fix it.
I’ve tried that, but when I unachor them, they just dissapear (or fall through the ground, I’m not sure) and I’m not able to even to get them.
Operatik
(Operatik)
April 1, 2020, 7:10am
#4
Unanchor them through script after touching them, that’s what he meant.
Txppin
(Txppin)
April 1, 2020, 7:12am
#5
I am assuming the script’s parent is a part with a mesh and not a meshpart here.
Here’s the code:
debounce = true
function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
h = Instance.new("Hat")
p = Instance.new("Part")
h.Name = script.Parent.Name
p.Parent = h
p.Position = hit.Parent:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(1.045, 1.045, 1.045)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentForward = Vector3.new(-0, -0, -1)
h.AttachmentPos = Vector3.new(0, 0.5, -0.2)
h.AttachmentRight = Vector3.new(1, 0, 0)
h.AttachmentUp = Vector3.new(0, 1, 0)
wait(2.5)
debounce = true
end
end
script.Parent.Touched:connect(onTouched)
Make sure it’s inside of a script
It was indeed a part with a mesh, but the script still didn’t work, sir. ;-;
Txppin
(Txppin)
April 1, 2020, 7:25am
#7
What’s the issue now? I tested out the script myself.
Well, the same thing as before happened. The character is sent to the hat and gets stuck.
Txppin
(Txppin)
April 1, 2020, 7:27am
#9
Add me on discord at Josh.#8574
Firzal_VX
(lolplomer)
April 1, 2020, 7:33am
#10
Anchor it, when the accessory wore, unanchor it
Oficcer_F
(Oficcer_F)
April 1, 2020, 7:35am
#11
I’d probably clone the hat and disable anchoring on the CLONE. This way, multiple people can use the hat and you can use it often and less buggy.
Could you tell me how do I do that? I’m still new to scripting, I’m sorry.
Oficcer_F
(Oficcer_F)
April 1, 2020, 8:18am
#13
To clone an object, take the object for example:
cloneHat = myHatVariable:Clone()
Then you have a clone of the hat. Then you just do the same as you do in the script but instead of using the original hat, use the clone.
And I add that under the function onTouched(hit) line?
Oficcer_F
(Oficcer_F)
April 1, 2020, 8:23am
#15
Exactly. Then you make the cloneHat.Anchored = false and then just switch your hat mesh variable, I beleive tha tin your case is “h” to cloneHat or whatever the clone is called.