Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Roblox "Loot Crate" Gamble system script gives me W006, What does it want me to do?

Asked by 14 days ago
Edited 14 days ago

Im Trying to do a "Gamble" System similar to jailbreak and Murder Mysteries Loot Boxes. On this script, ive got a W006 warning on Line87, and i have no idea what it wants me to do Again, its on Line 87.

local m = {}

--get item
local items = require(game.ReplicatedStorage.Items)

---variables
local player = game.Players.LocalPlayer
local gui = player("WaitForChild","PlayerGui")
local ui = gui("WaitForChild","ui")
local elements = gui("WaitForChild","Elements")

--function
    function m.getRarity(type)
        for a,b in ipairs(items.Rarities) do
            if b.name==type then
                return b
            end
        end
    end

    function m.createItem()
        local object = elements("WaitForChild","item"):Clone()
        local scaledSize = math.floor((object.Size.X.Scale*m.settings.cUI.AbsoluteSize.Y)+0.5)/m.settings.cUI.AbsoluteSize.X
        --Get / Set Types
        local types = {}
        for a,b in ipairs(m.settings.case.items) do
            for d,c in ipairs(items.Items) do
                if c.name==b then
                    local r = m:getRarity(c.rarityType)
                    for t=1,r.rarity*10 do
                        table.insert(types,c)
                    end
                end
            end
        end
        --select item
        local item = types[m.settings.prng:NextInteger(1,#types)]
        local itemType = m:getRarity(item.rarityType)

        --set other properties
        object.BorderColor3 = itemType.Color
        object.rarityMark.BackgroundColor3 = itemType.Color
        object.Name = item.name
        object.itemImage = "rbxassetid//"..item.imageID

        --set position
        object.Position = (m.settings.lastObject and
            m.settings.lastObject.Position+UDim2.new(scaledSize,0,0,0)+m.settings.offset) or UDim2.new(-scaledSize/2,0,0.5,0)
        --set parent
        object.parent = m.settings.cUI

        --set few variables
        m.settings.lastObject = object
        table.insert(m.settings.objects, object)
    end

    function m:check()
        for a,b in ipairs(m.settings.objects)do
            local scaledSize = b.AbsoluteSize
            if b.AbsolutePosition.X <= -scaledSize.x+m.settings.offset.X.Offset then
                table.remove(m.settings.objects,a)
                b:Destroy()
                m.createItem()
                m.check()
                break
            end
        end
    end

    function m:update()
        m.settings.speed = math.max(m.settings.speed-(0.03/m.settings.spinLength),0)
        m.settings.newAccel = m.settings.accel*math.sin((math.pi/2)*m.settings.speed)
        for a,b in ipairs(m.settings.objects)do
            b.Position = b.Position-UDim2.new(m.settings.newAccel/m.settings.cUI.AbsoluteSize.X,0,0,0)
        end
        if m.settings.newAccel==0 then m:result() end
    end

    function m:result()
        --disconnect
        m.render:disconnect()

        --get selected item
        local item
        for a,b in ipairs(m.settings.objects) do
            local left,right = b.AbsolutePosition.X/m.settings.cUI.AbsoluteSize.X,
            (b.AbsolutePosition.X+b.AbsoluteSize.X)/m.settings.cUI.AbsoluteSize.X
            if left <=0.5 and right >=0.5 then item=b break end
        end
        if item then
            m.newResult = item
        else
            local closestItems = {}
            for a,b in ipairs(m.settings.objects) do
                table.insert(closestItems,{
                mag=(Vector2.new(b.AbsolutePosition.X/m.settings.cUI.AbsoluteSize.X,0)-Vector2.new(0.5,0)).magnitude;
                item=b;
                })
            end
            table.sort(closestItems,function(a,b) return a.mag<b.mag end)
            m.newResult = closestItems[1].item
        end
    end

    function m:create(caseType)
        --Setings
        m.settings = {
            case=items.Cases[caseType];
            cUI=elements("WaitForChild","caseUI"):Clone();
            objects={};
            prng=Random.new();
            offset=UDim2.new(0,25,0,0);
            accel=30;
            speed=1;
            spinLength=5;
        }
        m.newResult=nil

        --presetup
        m.settings.cUI.Parent = ui
        for t=1,15 do
            m:createItem()
        end
        --services
        m.render = game("GetService","RunService").RenderStepped:connect(function()
            m:update()
            m:check()
        end)

        --wait for result
        repeat wait() until m.newResult

        --getrid of ui
        spawn(function()
            wait(1)
            m.settings.cUI.TweenPosition(UDim2.new(0,0,1.15,0),"Out","Sine",1,true,function() m.settings.cUI:Destroy() end)
        end)

--return result
return m.newResult
    end

    return m
0
Why are you using __namecall here? (game("GetService", "RunService"), elements("WaitForChild", "item"), ect)??? incapaxx 3270 — 14d
0
Be careful on the term gamble. Roblox does not allow gambling as a feature in games so you need to 'skimp' around the topic with how you implement it. alphawolvess 1674 — 14d
0
Change your local left,right to 1 line instead of 2 misiunicholas 52 — 14d
0
@alphawolvess gambling is fine as long as it's in-game currency being gambled. That is, people should not have to buy in-game currency with real robux, or robux directly being gambled incapaxx 3270 — 14d
0
Thank you comment3, This solved my problem! Stuffy_flowerx3 19 — 14d

Answer this question