Hello, I’m trying to make a system where you start out with one hat then once you have a certain amount of points you get a new hat. It gives the player the starter hat but when it goes over the amount of points that are needed to switch hats it does nothing and doesn’t give me any errors
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local palHair = Instance.new("Accessory")
palHair.Name = "PalHair"
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(1,1.6,1)
handle.Parent = palHair
local faceFrontAttachment = Instance.new("Attachment")
faceFrontAttachment.Name = "HatAttachment"
faceFrontAttachment.Position = Vector3.new(0, 0.35, 0.25)
faceFrontAttachment.Parent = handle
local mesh = Instance.new("SpecialMesh")
mesh.Name = "Mesh"
mesh.Scale = Vector3.new(1, 1.05, 1)
mesh.MeshId = "rbxassetid://83293901"
mesh.TextureId = "rbxassetid://83284747"
mesh.Parent = handle
humanoid:AddAccessory(palHair)
game.Players.PlayerAdded:Connect(function(player)
if player.leaderstats.Robux.Value <= 25 then
local Players = game:GetService("Players")
local function playerAdded(player)
player.CharacterAppearanceLoaded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
local accessories = {}
humanoid:RemoveAccessories()
wait(5)
if player and player.Character and player.Character == character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
for _, accessory in pairs(accessories) do
humanoid:AddAccessory(accessory)
end
end
end
accessories = nil
end)
end
for _, player in pairs(Players:GetPlayers()) do
playerAdded(player)
end
Players.PlayerAdded:Connect(playerAdded)
end
end)
-- second script that gives the new hat
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local function playerAdded(player)
if player.leaderstats.Robux.Value <= 25 then
local shaggy = Instance.new("Accessory")
shaggy.Name = "Shaggy"
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(1,1.6,1)
handle.Parent = shaggy
local faceFrontAttachment = Instance.new("Attachment")
faceFrontAttachment.Name = "HatAttachment"
faceFrontAttachment.Position = Vector3.new(0.12, 0.4, -0.07)
faceFrontAttachment.Parent = handle
local mesh = Instance.new("SpecialMesh")
mesh.Name = "Mesh"
mesh.Scale = Vector3.new(1.07, 1.07, 1.07)
mesh.MeshId = "rbxassetid://19999424"
mesh.TextureId = "rbxassetid://20571982"
mesh.Parent = handle
humanoid:AddAccessory(shaggy)
game.Players.PlayerAdded:Connect(playerAdded)
end
end