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

How do I make rarity spawn chance?

Asked by 3 years ago

I am trying to make a game where it spawns an item at a specific time like in the game shindo life. I have already made the time, but I have no idea how to make an item spawn at that time. Thanks.

1 answer

Log in to vote
0
Answered by
Jo1nts 134
3 years ago
Edited 3 years ago

This consists of math.random which generates a random number, aka chances of the item spawning. https://developer.roblox.com/en-us/api-reference/lua-docs/math

Make sure you have your item in Replicated storage

local time = 5 -- change time
local item = game.ReplicatedStorage.Part

local function spawnitem()
    local spawning = item:Clone()
    spawning.Parent = game.Workspace
end

while wait(time) do
local chance = math.random(1,2) -- 50% chance
    if chance == 1 then spawnitem()
        print(chance)
    end
end

0
for a 50% chance, you would want to choose between two numbers, so you would do math.random(1, 2) OfficerBrah 494 — 3y
0
for a 50% chance, you would want to choose between two numbers, so you would do math.random(1, 2) OfficerBrah 494 — 3y
0
typo mb Jo1nts 134 — 3y
Ad

Answer this question