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

I was making a script and i couldnt figure out why it wouldnt work can someone help me? [closed]

Asked by
Xeziux 0
8 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
game.Player.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        Character:WaitForChild("Torso")
        Character:SetTorsoCframe(Cframe.new(0,25050,0))
    end)
end)

local function GetOreFromId(Id)
    for i,Ore  in pairs(game.ReplicatedStorage.Ores:GetChildren()) do
        if Ore.Id.Value == Id then
            return Ore
        end
    end


local function Gamble(y)
    local Lottery = {}
    for _,Ore in pairs(game.ReplicatedStorage.Ores:GetChildren()) do
        local MaxDepth,MinDepth = (Ore.MaxDepth.Value > 0 and Ore.MaxDepth.Value) or 9999, (Ore.MinDepth.Value > 0 and Ore.MinDepth.Value) or 1
        local Range = MaxDepth - MinDepth
        local MinDistance = y - MinDepth
        local MaxDistance = MaxDepth - y
        local MaxRarity, MinRarity = Ore.MaxRarity.Value, Ore.MinRarity.Value
        local Chance = math.ceil(((MinDistance/Range) * MinRarity * (MaxDistance/Range) * MaxRarity) /2)
        for i=1,Chance do
            table.insert(Lottery,Ore.Id.Value)
        end
    end
    local Id = Lottery[math.random(1,#Lottery)]
    return GetOreFromId(Id)
end

local function GenerateOre(x,y,z)
    local Ore = Gamble(y):Clone()
    Ore.Parent = workspace.Mine
    Ore.Position = Vector3.new(0 + x*6,25000 + y*(-6) + z*6)
end

math.random(os.time())

for x=1,20 do
    for z=1,20 do
        GenerateOre(x, 1, z)
end
0
Use the button at the top of the textbox when editing your question to put your code into a lua code block. It's really hard to read otherwise. darkelementallord 686 — 8y
0
Give more description. You appear to be missing a few ends in your code. User#6546 35 — 8y

Closed as Too Broad by User#6546, koolkid8099, and unmiss

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?