Hello!
For context:
Previously, players in my game had to approach the 'giver part' to give their player an "accessory" (part with a mesh inserted into the player's character, i.e "Top Hat"). This worked fine until recently, when it was discovered that it was easier to have the 'giving part' clickable. This is where I'm having trouble, since I don't know how to correctly modify the script so that I can update the function...
Here's the script:
local debounce = true
function onTouched(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
local h = Instance.new("Hat")
local p = Instance.new("Part")
h.Name = "Top Hat"
p.Parent = h
p.Position = hit.Parent:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(2, 1, 1)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentPos = Vector3.new(0, 0, 0)
wait(5)
debounce = true
else
end
end
end
script.Parent.Touched:connect(onTouched)
Any help is appreciated, thank you. :)

1 comment
NOO YOU ANSWERED WHILE IM TYPING MY ANSWER :'(