So I have a script that choses an option that has a set probability of being chosen and then prints what it chose. My question is how can I make that script clone the item it choses. Example: I am the script is for an egg that will hatch into a dinosaur, right now it choses the dinosaur name but how can I make it put that dinosaur into the game. I assume I should put what its choosing like so
local Dilo = game.ServerStorage.Dilophosaurus
but I'm not sure exactly how to make it clone that dino. Would I have to put that dino in the location I want it and then move it to Serverstorage or Lighting?
Heres my current probability script in the egg.
local random=math.random(0,100) local randomchoice if random <= 15 then randomchoice = "Dilo" --15% print ("Dilophosaurus Hatched!") elseif random <= 40 and random >= 15 then --25% randomchoice = "Pachy" print ("Pachy Hatched!") elseif random <= 55 and random >= 40 then --15% randomchoice = "Trike" print ("Triceratops Hatched!") elseif random <= 70 and random >= 55 then --15% randomchoice = "Coeluro" print ("Coelurosaur Hatched!") elseif random <= 100 and random >= 70 then --30% randomchoice = "Compy" print ("Compy Hatched!") end
Any help on how this can work is greatly appreciated thanks ahead!
you would do something like this:
local egg=game.Workspace.Egg local dilo=game.ServerStorage.Dilo local randomchoice local function hatch if randomchoice=="Dilo" then local babydino=dilo:Clone() babydino.Parent=game.Workspace babydino.CFrame=egg.Positon egg:Destroy() print("a dilo has hatched!") end end