For some reason, Whenever this script is enabled, roblox core scripts begin spamming random part names from workspace and “rendered” in the output. this also drops the game to a crawling 0.4 fps, so its pretty important i figure out why. script below:
local Players = game.Players
local box = script.Parent
local plr = Players.LocalPlayer
local id = plr.UserId
local plrM = plr.Character
local stat = plr:WaitForChild("Stats")
local hats = stat:FindFirstChild("Hats")
local rep = game.ReplicatedStorage
local templates = rep:WaitForChild("Templates")
local tem = templates:FindFirstChild("hatUItem")
local hatMs = rep:FindFirstChild("HatsModels")
local function Add(child)
if child:IsA("StringValue") then
local c = tem:Clone()
c.Parent = box
local index = child:GetAttribute("Index")
local hat = child.Value
c.Name = index
if hatMs:FindFirstChild(hat) then
c:FindFirstChild("Name").Text = hat
local r = hatMs:FindFirstChild(hat):Clone()
print(c.Name)
r.Parent = c
local sc = templates:FindFirstChild("thing"):Clone()
print(r.Name)
sc.Parent = r
sc.Enabled = true
end
end
end
local function Removed(child)
local index = child:GetAttribute("Index")
if child:IsA("StringValue") then
for i,v in box:GetChildren() do
if v.Name == index then v:Destroy() end
end
end
end
hats.ChildAdded:Connect(Add)
hats.ChildRemoved:Connect(Removed)