#why wont this work

1 messages · Page 1 of 1 (latest)

unreal stirrup
#

I'm trying to check for "OreGradient", and if it doesn't exist, then default to the color3 value. But it's not using the gradient, and instead the map breaks. Does anyone know how to fix this??

#
elseif Ore:FindFirstChild("OneIn") then
                if RareRandom:NextInteger(1, Ore.OneIn.Value) == 1 then
                    if RealOre:FindFirstChild("OreGradient") then
                            game.ReplicatedStorage.Announce:FireAllClients("A rare ore has spawned.",10,Ore.OreGradient.UIGradient,ColorSequence) else
                            game.ReplicatedStorage.Announce:FireAllClients("A rare ore has spawned.",10,Ore.OreColor.Value,Color3.new(0, 0, 0),1846398270)
                    return Ore
                end

#

this is the code that is breaking everything

knotty juniper
#

You're checking RealOre:FindFirstChild("OreGradient"), but then referencing Ore.OreGradient.UIGradient, which may not exist or may not be structured that way.

grave hamletBOT
#

studio** You are now Level 1! **studio

knotty juniper
#

I can try to fix the script if youd like

unreal stirrup
knotty juniper
#

It may not be structured or exist that way

#

Ill just fix the script

#

1 moment

unreal stirrup
#
local function Gamble(x,y,z,Cave)
    local Lottery = {}
    local oreids = {}
    local RunningTotal = 0

    for Index,Ore in pairs(Items) do
        local MaxDepth, MinDepth = Ore.MaxDepth.Value, Ore.MinDepth.Value
        if y >= MinDepth and y <= MaxDepth then
            local Range = MaxDepth - MinDepth + 1
            local MinDistance = y - MinDepth + 1
            local MaxDistance = MaxDepth - y + 1
            if Ore:FindFirstChild("UniquePosition") and Ore.UniquePosition.Value == Vector3.new(x,y,z) then
                return Ore
            elseif Ore:FindFirstChild("OneIn") then
                if RareRandom:NextInteger(1, Ore.OneIn.Value) == 1 then
                    if RealOre:FindFirstChild("OreGradient") then
                            game.ReplicatedStorage.Announce:FireAllClients("A rare ore has spawned.",10,Ore.OreGradient.UIGradient,ColorSequence) else
                            game.ReplicatedStorage.Announce:FireAllClients("A rare ore has spawned.",10,Ore.OreColor.Value,Color3.new(0, 0, 0),1846398270)
                    return Ore
                end
            else
                local MaxRarity, MinRarity = Ore.MaxRarity.Value, Ore.MinRarity.Value
                local Chance = math.ceil(((MinDistance/Range) * MinRarity + (MaxDistance/Range) * MaxRarity) / 2)
                if Chance > 0 and (Cave or not Ore:FindFirstChild("Cave")) then
                    RunningTotal = RunningTotal + Chance
                    table.insert(Lottery,RunningTotal)
                    table.insert(oreids,Index)
                end
            end
        end
    end

    local pickone = math.random(1,RunningTotal)

    for Count,ID in pairs(Lottery) do
        if pickone <= ID then
            return Items[oreids[Count]]    
        end
    end
    return game.ReplicatedStorage.Ores.Stone
end

#

this is the full script

knotty juniper
#

Oh ok

unreal stirrup
#

well the full function

knotty juniper
#

Fixed

#

try it

#

I made Realore default to Ore because it wasnt defined elsewhere

#

and made return Ore happen after the Announce logic regardless of branch.

unreal stirrup
#

realore is referenced elsewhere in the script

knotty juniper
#

Oh

#

I didint know

#

Lol

unreal stirrup
#

problem is the script is 1.1k lines soo

knotty juniper
#

I was just fixing the script

#

So

#

Thats not the full script

#

is it

unreal stirrup
#

i cant send the script in 1 msg, i can send in 4 or 5 if you need me to

grave hamletBOT
#

studio** You are now Level 1! **studio

knotty juniper
#

Just do it as downloaded

unreal stirrup
#

everything else works tho, its literally just that part

knotty juniper
#

Let me know if it fixes it

unreal stirrup
#

the Announcer works too, it just doesn't use the gradient which i am confused about (im new to scripting)

knotty juniper
#

Yeah

unreal stirrup
knotty juniper
#

hold on

#

Im dealing with 2 people rn

rose copper
#

bacon