so i have this script that when the Values Are 1 it automatically Puts the Character in The Player Folder
this is the Script
local chars = game.ReplicatedStorage:WaitForChild("Characters")
local classNames = {"Accessory", "Shirt", "Pants", "ShirtGraphic", "BodyColors"}
game.Players.PlayerAdded:Connect(function(plr)
local OwnedCharactersValue = Instance.new("Folder", plr)
OwnedCharactersValue.Name = "OwnedCharactersValue"
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local Cash = Instance.new("IntValue", leaderstats)
Cash.Name = "Cash"
Cash.Value = 0
local OwnedCharacters = Instance.new("Folder", plr)
OwnedCharacters.Name = "OwnedCharacters"
for i, char in pairs(chars:GetChildren()) do
local NewValue = script.Value:Clone()
NewValue.Name = char.Name
NewValue.Parent = OwnedCharactersValue
end
for i, Giver in pairs(chars:GetChildren()) do
local CharactersValue = OwnedCharactersValue:GetChildren()
for i = 1, #CharactersValue do
if CharactersValue[i].Value == 1 then
chars.CharactersValue.Name:Clone().Parent = OwnedCharacters
end
end
end
end)
game.ReplicatedStorage.CharacterRE.OnServerEvent:Connect(function(plr, isBuying, character)
if not chars:FindFirstChild(character) then
return
end
if isBuying and not plr.OwnedCharacters:FindFirstChild(character) then
local price = chars:FindFirstChild(character).Price.Value
local plrCash = plr.leaderstats.Cash
local OwnedCharactersValue = plr.OwnedCharactersValue
if price <= plrCash.Value then
plrCash.Value -= price
local CharactersValue = OwnedCharactersValue:FindFirstChild(character)
CharactersValue.Value = 1
chars[character]:Clone().Parent = plr.OwnedCharacters
end
elseif not isBuying and plr.OwnedCharacters:FindFirstChild(character) and plr.Character and plr.Character:FindFirstChild("Humanoid") then
for i, descendant in pairs(plr.Character:GetDescendants()) do
if table.find(classNames, descendant.ClassName) or descendant:IsA("Decal") and descendant.Parent.Name == "Head" then
descendant:Destroy()
end
end
for i, descendant in pairs(plr.OwnedCharacters[character]:GetDescendants()) do
if table.find(classNames, descendant.ClassName) then
descendant:Clone().Parent = plr.Character
elseif descendant:IsA("Decal") and descendant.Parent.Name == "Head" then
descendant:Clone().Parent = plr.Character.Head
end
end
end
end)
the Script is not really Mine Tbh