i still have no idea why this isn't considered a valid quesiton because I attempted to do this and nobody wants to help

I've been trying to make a script that, when you click it, you wear a hat. I've tried this script and all it does is create the hat but it doesn't go on your character, and your hats aren't removed. Here's the code:

local pl = game.Players.LocalPlayer
local c = pl.Character
local debounce = false

script.Parent.MouseButton1Up:connect(function()
if script.Parent.ImageColor3 == Color3.new("255","255","255") then
	local d = c:GetChildren()
	for i=1, #d do
		if d[i].className == "Hat" then
		d[i]:remove()
	end
		wait(0.1)
		local helm = game.Lighting:FindFirstChild("Genie")
		local cl = helm:Clone()
		cl.Parent = c
	
	debounce = true
	if debounce == true then
	debounce = false
	local h = Instance.new("Hat")
		local p = Instance.new("Part")
		h.Name = "Hat"  
		p.Parent = h
		p.Position = c:FindFirstChild("Head").Position
		p.formFactor = 0
		p.Size = Vector3.new(-0,-0,-1) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		script.Mesh:clone().Parent = p
		h.Parent = c
		h.AttachmentPos = Vector3.new(0.125, 1.65, 0.18) --
		wait(5)
		debounce = false
	end
	end
	end
end)

3 comments

0

You're not even attempting to weld the hat. Provide an attempt of that.. otherwise this is considered not constuctive.

0

I just want it on the character's head come on...

0

And I did provide an attempt for the hat in the last if statement, I may not have done most of it but I still have a great deal of attempt here.