Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i add a hat on enter?

Trying to give a player a hat when they enter the game... but it no work

local debounce = false
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
wait()
		
		if char:findFirstChild("Hat") == nil then
		local Hat = Instance.new("Accessory",char)
		local MeshP = Instance.new("Part",Hat)
		local Mesh = Instance.new("SpecialMesh",MeshP)		
		MeshP.Position = char.Head.Position
	    Hat.Name = "Hat"
		MeshP.Name = "Handle"
		Mesh.MeshId = "rbxassetid://19326912"
		MeshP.Size = Vector3.new(1,2,2) 
		MeshP.CanCollide = true
		MeshP.Locked = true
		local Weld = Instance.new("Weld",MeshP)
		Weld.Part0 = char.Head
		Weld.C0 = char.Head.CFrame:inverse()
		Weld.Part1 = MeshP
		Weld.C1 = MeshP.CFrame:inverse()
		end
end)
end)

1 answer

you have an error with if char:findFirstChild("Hat") == nil then, its supposed to be if char:FindFirstChild("Hat") == nil then, with a captial F.

1 comment

0

... That isn't and error

This discussion is preserved as it was. New answers, comments, and votes are closed.