Apologies for the vague title, I couldn’t explain my issue clearly without writing a paragraph here.
Hey,
I am trying to make it so the decals and items in my games use strings instead of numbers so they can be easily seperated instead of me using numbers.
Here’s a visual representation of the issue:
This uses numbers and as you can see… The eyes could use names instead of straight up numbers, and same for the others. The reason of this is due to this line of code i made that inserts bundles that the player owns (Packs that add more values and could mess up the numbers + It is randomized so it will be very inconsistent and the eyes and mouths could be randomized)
Here’s the code that imports the bundles in, and if you need any scripts, (e.g Clientside, Serverside customization) then you can simply ask.
task.spawn(function()
if Player:FindFirstChild("PlayerBundles") then
local TargFolder = Player:FindFirstChild("PlayerBundles")
for _, Bundle in TargFolder:GetChildren() do
if Bundle:IsA("BoolValue") then
if Bundle.Value == false then return end
if MainBundles:FindFirstChild(Bundle.Name) then
local FolderToClone = MainBundles:FindFirstChild(Bundle.Name)
for _, InterestingType in pairs(FolderToClone:GetChildren()) do
if Storage:FindFirstChild(InterestingType.Name) then
local KnownChildren = #Storage:FindFirstChild(InterestingType.Name):GetChildren()
for _, EveryThing in pairs(InterestingType:GetChildren()) do
local Clone = EveryThing:Clone()
Clone.Parent = Storage:FindFirstChild(InterestingType.Name)
KnownChildren += 1
Clone.Name = KnownChildren
end
end
end
end
end
end
end
end)
If I understand it correctly, you’re trying to give them names instead of just having numbers. Couldn’t you use Bundle.Name to change the text instead of using what I assume are identifying numbers?
I have thought of that, but this is the server function that is responsible for all those numbers and now I am a bit puzzled…
EDIT: I just had a idea but I am unsure how to approach it. How would I be able to put a intValue inside of these images and them compare them based off that?
function ChangerNumber(Type,Key)
--------------------
local SelectFolder = Storage:FindFirstChild(Type.Name)
if SelectFolder == nil then return end
--------------------
local MaxNumber = #SelectFolder:GetChildren()
if MaxNumber >1 then
if Key == "Right" then
if Type.Value >= MaxNumber then
Type.Value = 1
else
Type.Value += 1
end
elseif Key == "Left" then
if Type.Value <= 1 then
Type.Value = 1
else
Type.Value -= 1
end
end
else return
end
end
I’ve replaced all the numerical playerdata with strings since I want the name of it instead of just 1,2,3.
function ChangerNumber(Type,Key)
--------------------
local SelectFolder = Storage:FindFirstChild(Type.Name)
if SelectFolder == nil then return end
--------------------
local MaxNumber = #SelectFolder:GetChildren()
if MaxNumber > 1 then
if Key == "Right" then
if Type.Value >= MaxNumber then
Type.Value = 1
else
Type.Value += 1
end
elseif Key == "Left" then
if Type.Value <= 1 then
Type.Value = 1
else
Type.Value -= 1
end
end
else return
end
end
Ican assure you, the issue isn’t just this one script. You should change the functional organization and the code would drastically reduce by about 50 to 60%, and would be more manageable and less prone to logical errors
“Bundle 1” now has its value as TRUE and is now cloned into the main Custom folder, being accessible.
The player can choose their purchased bundle of things, pretty cool. The problem is that now the faces/eyes and other bundles inserted could be randomized in any way so its complete RNG or Hat they have now!
It all goes well until number 3.
The scripts and things I have now look very worn down and heavily out of date and look very bad… Here’s a simple image to show it’s weirdness: