Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make a script clone an item from storage or lighting at probability? [Solved]

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!

4 comments

0

Sorta. You should be able to do "local Dilo = game.ServerStorage.Dilophosaurus:Clone()" followed by "Dilo.Parent = workspace" if you want the clone to be put into the game (which is what I'm assuming).

0

ok first things first, the location, it's best to place it in replicated storage or server storage

0

There is no reason to store objects in Lighting. Lighting is used for skyboxes, post effects, and environmental lighting. I don't think a "dilophosaurus" is a skybox or post effect.

0

lol ok I will put them in server storage

1 answer

✓ Accepted answer

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

6 comments

0

i really love helping you so if you want more personal help we can do "Team Build" on Roblox Studio!

0

that would be great! I have been working on this world for a while now and my partner is leaving soon I could totally use your help and give you credit for it too!

0

ok, proffesional acount is Zendalu so please message me anytime!!

0

Ok i sent you messages on your Zendaya774isstupid account but I will resendd them to Zendalu

0

I cant message Zendalu until were friends I belive

0

k

This discussion is preserved as it was. New answers, comments, and votes are closed.