- What do you want to achieve?
I need a “mixing system” that mixes elements. I tried doing it but it doesn’t work.
- What is the issue?
What I made makes the wrong compound when mixing elements and sometimes doesn’t make anything.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried looking on the devforum but I didn’t know what to look for.
Script One (Local Script)
local Current -- is the current flask/beaker its a basepart
local Number = 0
local Number2 = 0
local Compound
for i,v in pairs(ElementsInContainer) do --This makes values of the elements in the 'Current' variable and it works
if Storage:FindFirstChild(v.Name) then
Storage[v.Name].Value += 1
else
local Clone = ElementValue:Clone()
Clone.Parent = Storage
Clone.Name = v.Name
Clone.Value = 1
Clone.Parent = Storage
end
end
-- After this I don't know what to do. this is what I tried
for i,v in pairs(ElementsModule.Compounds) do
for x,y in pairs(v.ComposedOf) do
for z,t in pairs(Storage:GetChildren()) do
if y.Name == t.Name then
Compound = v.Name
end
end
end
end
local a = ElementsModule.Compounds[Compound]
if a and Compound then
for i,v in pairs(a.ComposedOf) do
Number2 += v.Amount
end
else
return
end
print(Number, Number2, Compound)
if Number == Number2 then -- This is a very bad way of doing it because if a different compound also adds up to (lets say 5) it wont work
print("Made Compound: "..Compound)
MainModule.Spawn("Compounds", Compound, Current.Position)
end
Elements Module (Module Script)
local Elements = {
Elements = {
["Hydrogen"] = {
Name = "Hydrogen",
Symbol = "H",
AtomicNumber = 1,
AtomicMass = 1.0078,
Color = Color3.fromRGB(255, 0, 0),
PhysicalColor = Color3.fromRGB(100, 100, 100),
Material = Enum.Material.Plastic,
Reactors = {-- Reactors are just a visual thing
[1] = "Oxygen",
},
},
["Oxygen"] = {
Name = "Oxygen",
Symbol = "O",
AtomicNumber = 8,
AtomicMass = 15.999,
Color = Color3.fromRGB(255, 178, 126),
PhysicalColor = Color3.fromRGB(0, 50, 255),
Material = Enum.Material.SmoothPlastic,
Reactors = {
[1] = "Hydrogen",
},
},
},
Compounds = {
["Water"] = {
Name = "Water",
Symbol = "H₂O",
AtomicMass = 18.02,
Color = Color3.fromRGB(0, 100, 255),
PhysicalColor = Color3.fromRGB(0, 100, 255),
Material = Enum.Material.Glass,
ComposedOf = {
["Hydrogen"] = {Name = "Hydrogen", Amount = 2},
["Oxygen"] = {Name = "Oxygen", Amount = 1},
},
Reactors = {},
},
-- there are more compounds and elements but I only gave what's needed
}
}
return Elements
Its supposed to make compounds based of what’s in the beaker/flask. if there is 2 Hydrogen and 1 Oxygen in there it makes water.
This is my first time making a topic so tell me if I’m doing something wrong