Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 5 years ago
Edited 5 years ago

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!

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). ScrewDeath 153 — 5y
0
ok first things first, the location, it's best to place it in replicated storage or server storage Zendaya774isstupid 50 — 5y
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. User#19524 175 — 5y
0
lol ok I will put them in server storage JakeDaBeAat 13 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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
0
i really love helping you so if you want more personal help we can do "Team Build" on Roblox Studio! Zendaya774isstupid 50 — 5y
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! JakeDaBeAat 13 — 5y
0
ok, proffesional acount is Zendalu so please message me anytime!! Zendaya774isstupid 50 — 5y
0
Ok i sent you messages on your Zendaya774isstupid account but I will resendd them to Zendalu JakeDaBeAat 13 — 5y
View all comments (2 more)
0
I cant message Zendalu until were friends I belive JakeDaBeAat 13 — 5y
0
k Zendaya774isstupid 50 — 5y
Ad

Answer this question