To put it simply I have eggs which will hatch into dinosaurs kind of at random but with probabilities. I believe I have the probabilities part is correct but I'm not sure how to make the script do something with the probabilities. What I mean is I dont know how to make the script chose one of the probabilities and make that dino "hatch" from it. This is very important for our game and I couldn't find help anywhere else any help is greatly appreciated. Im sorry for the question but I'm not very experienced scripting.
The script of probabilities
local Dilo = game.Workspace.Dilophosaurus
local Pachy = game.Workspace.Pachy
local Trike = game.Workspace.Triceratops
local Coeluro = game.Workspace.Coelurosaur
local Compy = game.Workspace.Compy
local chances = {
['Dilo'] = 20,
['Pachy'] = 20,
['Trike'] = 10,
['Coeluro'] = 20,
['Compy'] = 30,
}
local results = {}
table.foreach(chances, function(key, value)
for i = 1, value do
table.insert(results, key)
end
end)
local random = math.random(#results)

6 comments
oops! i meant if random<=50 then
Please indent your code
sorry i dont really indent my comments so idk how to do it right
Ok thanks! How would I add more choices, I get above 50 or under 50 or even like 70, 30 but how would i do like 35, 30 and 25 etc
i'll use your example above to answer this
ok thanks ill test it out