I got this script from a loot crate tutorial on YouTube but this for 2 choices.

math.randomseed(tick())
local random = math.random(1,100)
function onClick(plr)
    script.Disabled = true
    if random >=  1 or random <= 50 then
        local item = game.ServerStorage:FindFirstChild("AR")
        item:Clone().Parent = plr.Backpack

    elseif random >= 51 or random <= 100 then
        local item2 = game.ServerStorage:FindFirstChild("Crossbow")
        item2:Clone().Parent = plr.Backpack
    end
    script.Parent:Destroy()
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)

I TRIED to solve it by doing this... But this didn't turn out as expected. It gives the same random weapon every time.

math.randomseed(tick())
local random = math.random(1,8)
function onClick(plr)
    script.Disabled = true
    if random == 1 then
        local item = game.ServerStorage:FindFirstChild("AR")
        item:Clone().Parent = plr.Backpack

    elseif random == 2  then
        local item2 = game.ServerStorage:FindFirstChild("Crossbow")
        item2:Clone().Parent = plr.Backpack

    elseif random == 3  then
        local item3 = game.ServerStorage:FindFirstChild("Grenade Launcher")
        item3:Clone().Parent = plr.Backpack

    elseif random == 4  then
        local item4 = game.ServerStorage:FindFirstChild("Pistol")
        item4:Clone().Parent = plr.Backpack

    elseif random == 5  then
        local item5 = game.ServerStorage:FindFirstChild("Railgun")
        item5:Clone().Parent = plr.Backpack 

    elseif random == 6  then
        local item6 = game.ServerStorage:FindFirstChild("Rocket Launcher")
        item6:Clone().Parent = plr.Backpack

    elseif random == 7  then
        local item7 = game.ServerStorage:FindFirstChild("Shotgun")
        item7:Clone().Parent = plr.Backpack

    elseif random == 8  then
        local item8 = game.ServerStorage:FindFirstChild("Sniper")
        item8:Clone().Parent = plr.Backpack
    end
    script.Parent:Destroy()
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)

1 comment

0

Same thing happening to me every time. I don't know how to fix this at all...