script.Parent.Touched:Connect(function(hit)
local player = workspace[hit.Parent.Name]
local plr = game.Players:GetPlayerFromCharacter(player)
local playermodel = hit.Parent:FindFirstChild("Humanoid")
if plr.TeamColor == game.Teams["Medical Department"].TeamColor then
local dustmask = Instance.new("Accessory")
dustmask.Name = "MDHat"
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(1, 0.8, 1)
handle.Parent = dustmask
local faceFrontAttachment = Instance.new("Attachment")
faceFrontAttachment.Name = "FaceFrontAttachment"
faceFrontAttachment.Position = Vector3.new(0, 0, -0.5)
faceFrontAttachment.Parent = handle
local mesh = Instance.new("SpecialMesh")
mesh.Name = "Mesh"
mesh.Scale= Vector3.new(1, 1, 1.05)
mesh.MeshId = "rbxassetid://20928923"
mesh.TextureId = "rbxassetid://20928919"
mesh.Parent = handle
end
end)
I have checked, and I am on the correct team

1 comment
you have not set the parent of the hat