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

Why does my case system only give one type of skin?

Asked by 7 years ago

It's meant to insert a random skin into the inventory but it's only giving holiday crowns

Num = 0



function script.RemoteFunction:OnServerInvoke(id)
    math.randomseed(tick())
    Num = math.random(1,100)
    local Skin = "nil"
    if Num > 50 then
        Skin = "blue"
    else
        if Num > 10 then
            Skin = "Pirate"
        else
            Skin = "Holiday Crown"
        end
    end

    local Inv = game:GetService("DataStoreService"):GetDataStore("Inventory"):GetAsync(id)
    table.insert(Inv,Skin)
    game:GetService("DataStoreService"):GetDataStore("Inventory"):SetAsync(id,Inv)
    return Skin
end

2 answers

Log in to vote
0
Answered by
IcyMizu 122
7 years ago

you add a remote event

0
??? the problem is that the only skin being inserted is pirate xXRealFurryKittenXx 20 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

This happened to me once when I was experimenting with math.randomseed. I did this in command bar

math.randomseed(tick()) print(math.random(1,10)) --prints 3 all the time

You are only supposed to do math.randomseed before you do randoming. For example,

math.randomseed(tick())
function something(times)
    local times = times or 1
    if times > 20 then
        return
    end
    print(math.random(1, 10))
    something(times + 1)
end
something()

Hope this helps!

Answer this question