Yep so if you wanted to through a script you could iterate through every single hat a player has on them.
-- SERVICES
local Players = game:GetService("Players")
-- VARIABLES
local DesignatedMaterial = "ForceField"
-- FUNCTIONS
local function characterAdded(character)
for _, accessory in pairs(character:GetChildren()) do
if accessory:IsA("Accessory") then
local handle = accessory:FindFirstChildWhichIsA("BasePart")
if handle then
local material
local success, err = pcall(function()
material = Enum.Material[DesignatedMaterial]
end)
if not success or not material then
warn("Invalid material:", DesignatedMaterial)
return
else
handle.Material = material
print("Set material for accessory:".. accessory.Name)
end
end
end
end
end
local function playerAdded(player)
characterAdded(player.Character or player.CharacterAdded:Wait())
player.CharacterAdded:Connect(characterAdded)
end
-- RUNTIME
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(playerAdded)(player)
end
Players.PlayerAdded:Connect(playerAdded)
Put this script into serverscriptservice, or wherever you handle characterloading.
-- SERVICES
local Players = game:GetService("Players")
-- VARIABLES
local DesignatedMaterial = "ForceField"
-- FUNCTIONS
local function characterAdded(character)
for _, accessory in pairs(character:GetChildren()) do
if accessory:IsA("Accessory") then
local handle = accessory:FindFirstChildWhichIsA("BasePart")
if handle then
local material
if handle:IsA("MeshPart") then
handle.TextureID = ""
else
handle:FindFirstChildOfClass("SpecialMesh").TextureId = ""
end
local success, err = pcall(function()
material = Enum.Material[DesignatedMaterial]
end)
if not success or not material then
warn("Invalid material:", DesignatedMaterial)
return
else
handle.Material = material
print("Set material for accessory:".. accessory.Name)
end
end
end
end
end
local function playerAdded(player)
characterAdded(player.Character or player.CharacterAdded:Wait())
player.CharacterAdded:Connect(characterAdded)
end
-- RUNTIME
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(playerAdded)(player)
end
Players.PlayerAdded:Connect(playerAdded)
What we did was add these lines:
if handle:IsA("MeshPart") then
handle.TextureID = ""
else
handle:FindFirstChildOfClass("SpecialMesh").TextureId = ""
end
This checks to see if the handle is a meshpart, because sometimes they are if you are using custom accessories if I recall correctly. Then we just override the textureid and set it to nothing.