How to make an alchemy system?


Any idea how to make a alchemy system?
I thought about making it this way:
Theres a value in cauldron and it goes up after adding ingredients
After pressing the brew button the game checks the value if the value for example is 4 the game fires a event that gives the potion to a player and if its lesser than 4 the counter resets and damages the player. But that won’t work in my case because you theoretically can make potions that require diffrent ingredients with 1 ingredient (example 1 root = 2 value 1 scroom = 1 value instead of 2 roots u can just put 4 scrooms and the result will be the same)

2 Likes

When evaluating what potion you made, use all the base ingredients.
So for example with food:
Water -> H (2x), O
Iced Tea -> Water, Tea -> C (6x), H (14x), O (7x)

just create some sort of table and each item has their own ‘’ Value’’ 1,2,3,etc

local tab = {
["Scrom"] = 1,
["Leaf"] = 2,
["Sand"] = 3,
}


about the :

1 ingredient (example 1 root = 2 value 1 scroom = 1 value instead of 2 roots u can just put 4 scrooms and the result will be the same)

i see that you want to check (on the server side preferably)
which items the player inserted

for this to work you need to make the caldron server-sided script,

– create a way to contact the server for example

  • Cauldron here:

create a invisible Part that acts like a invisible button ( not too hard to do it)

after pressing on it, fire a remote event that sends (The item you are holding on the hand)

it will sacrifice the item,

at the server side, the server will check IF

– you own this item ( at least 1)
– you are closer to the cauldron ( preventing exploits from 999 miles away)
– the name of the Item( so it will memorize it )

would looks something like this the server side:

local CauldronActivated = game.ReplicatedStorage.RemoteEvent < -- change the name

local serverVerify = { -- this is the server-sided table so it will not be able to exploit items
["Scrom"] = 1,
["Leaf"] = 2,
["Sand"] = 3,

}

CauldronActivated.OnServerEvent:Connect(function(player, ItemSelected)

-- create something like if distance is lesser than 10 then proceed -- < Optional

 if ItemSelected == serverVerify[ItemSelected]  then 

-- the ItemSelected is a string, since it is a '' Name of item '' 
--the server now will check if it exists on the [Server-side] Table

   if player["Artificial Inventory"]["ItemSelected"].ItemQuantity.Value > 1 then   
    -- now here i used a StringValue ( not hard to do this)
    -- to check if the player actually owns at least 1 of that item

         -- after that you can do the rest of the script here, the next part is about
-- inserting the value on a table or somewhere so the server can memorize it



  end
end

end)

another button to grab the potion would be, click on the Wood thing on the cauldron
and send another remote event asking for some potion

the server will check how many items and which type of items you inserted on the
‘’ server table’’

local ItemsInserted = { -- for example
["Scrom"] = 2,
["Leaf"] = 5,
["Stick"]  = 2
}

the max result is 4, but looks like the player inserted too much item

to ignore calculation with what you inserted if it exceed the number 4, just check if the value is highter than 4 and send an explosion ( made by the server )

what about the recipes?

– well i never tried this before, but i don’t know, if i get an idea i’ll return

For the recipes you would instead of using numbers you would probably use the object directly, something like:

local potionHealTable = {
[“Root”] = 1
[“Broom”] = 2
}

The end result would be 3, but I could only check the object and then give a certain potion

Okay say we have the ingredient. we pick it up put it in the pot. Say it is a tool for simplicity sake. It should connect to the touch of the water

Ingredients={}
Potentcy=0
AlchemPot.Touched:Connect(function(hit)

table.Insert(Ingredients,hit)
end)
So i would make these objects have some sort of special attributes
local Variable=hit:GetAttribute("")
Perhaps have a folder of alchemic items.
Items=game.ReplicatedStorage.Alchemy
if the hit is in the directory of items then do the table inset
if Items:FindFirstChild(hit.Name)~=nil then

end