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

How Do I Fix This Mystery Box Script to work again?

Asked by 3 years ago

Hi, Anyone to whoever is reading this i was attempting to fix this mystery box script from call of robloxia zombies and it went pretty bad with some errors and so that it can work again the main problem i manly think is that keybind is not detecting anything when i hold f if you want to check out the script its below me

Box = script.Parent 

Button1 = Box.Button1
Button2 = Box.Button2
Button3 = Box.Button3

Gun = Box.Gun

Owner = script.Owner
CurrentGun = script.CurrentGun
Guns =      {"Commando",                "CZ75",                 "Dragunov",                 "Famas",                        "G11",                      "Galil",                        "HK21",                      "HS-10",                    "Python",                   "RPK",                         "SPAS-12"}
GunDecals = {"51938680",                "47556261",             "48798663",                 "52030323",                 "52085569",                 "52130605",                 "51853033",              "57066730",                 "49153584",                 "56886794",                "47554367"}
GunSize =   {Vector3.new(1, 2.5, 5),Vector3.new(1, 2, 4),Vector3.new(1, 1.5, 6),Vector3.new(1, 2.5, 5), Vector3.new(1, 2.5, 5), Vector3.new(1, 2.5, 5), Vector3.new(1, 2.5, 5),Vector3.new(1, 2.5, 5),Vector3.new(1, 2.5, 2.5),Vector3.new(1, 2.5, 5),Vector3.new(1, 2.5, 5)}

function CycleWeapons() 
    LastGun = CurrentGun.Value
    Gun.Decal.Texture = "http://www.roblox.com/asset/?id="..GunDecals[CurrentGun.Value]..""
    Gun.Mesh.Scale = GunSize[CurrentGun.Value]
    Gun.Mesh.Offset = Vector3.new(0, -3.5, 0)
    cycles = math.random(40,50)
    for i = 1, cycles do
        wait(0.1)
        CurrentGun.Value = CurrentGun.Value + 1
        if CurrentGun.Value > #Guns then
            CurrentGun.Value = 1
        end
        if i == cycles then
            while true do
                if CurrentGun.Value == LastGun or game.Players:findFirstChild(Owner.Value).Backpack:findFirstChild(Guns[CurrentGun.Value]) ~= nil or game.Players:findFirstChild(Owner.Value).Character:findFirstChild(Guns[CurrentGun.Value]) ~= nil then
                    CurrentGun.Value = CurrentGun.Value + 1
                    if CurrentGun.Value > #Guns then
                        CurrentGun.Value = 1
                    end
                else
                    break
                end
                wait()
            end
        end
        Gun.Decal.Texture = "http://www.roblox.com/asset/?id="..GunDecals[CurrentGun.Value]..""
        Gun.Mesh.Scale = GunSize[CurrentGun.Value]
        Gun.Mesh.Offset = Vector3.new(0, ((i/cycles) * 3.5) -3.5, 0)
    end
end

DB = false
function onActivated()
    if DB == false and Button1.Text.Value == "Press F for a Random Weapon [Cost: 950]" then
        DB = true
        local Activate = nil
        if Button1.Activate.Value ~= nil then
            Activate = Button1.Activate.Value
        elseif Button2.Activate.Value ~= nil then
            Activate = Button2.Activate.Value
        elseif Button3.Activate.Value ~= nil then
            Activate = Button3.Activate.Value
        end
        if Activate ~= nil then
            if Activate.leaderstats.Points.Value >= 950 then 
                Owner.Value = Activate.Name
                game.Players:findFirstChild(Owner.Value).leaderstats.Points.Value = game.Players:findFirstChild(Owner.Value).leaderstats.Points.Value - 950
                game.Lighting.Counters:findFirstChild("Eternal Investments").Value = game.Lighting.Counters:findFirstChild("Eternal Investments").Value + 950
                game.Lighting.Counters:findFirstChild("I Like Those Odds").Value = game.Lighting.Counters:findFirstChild("I Like Those Odds").Value + 950
                Box.Lid1.Mesh.Scale = Vector3.new(0, 0, 0)
                Box.Lid2.Mesh.Scale = Vector3.new(1, 1, 1)
                Button1.Text.Value = ""
                Button2.Text.Value = ""
                Button3.Text.Value = ""
                wait(0.25)
                CycleWeapons()
                Button1.Text.Value = "Press F to Trade Weapons"
                Button2.Text.Value = "Press F to Trade Weapons"
                Button3.Text.Value = "Press F to Trade Weapons"
                for i = 1, 20 do
                    if Button1.Text.Value ~= "Press F to Trade Weapons" then
                        break
                    else
                        wait(0.5)
                    end
                end
                if Button1.Text.Value == "Press F to Trade Weapons" then
                    Owner.Value = ""
                    Box.Lid1.Mesh.Scale = Vector3.new(0.99, 0.3, 0.99)
                    Box.Lid2.Mesh.Scale = Vector3.new(0, 0, 0)
                    Button1.Text.Value = ""
                    Button2.Text.Value = ""
                    Button3.Text.Value = ""
                    Gun.Decal.Texture = ""
                    wait(2)
                    Button1.Text.Value = "Press F for a Random Weapon [Cost: 950]"
                    Button2.Text.Value = "Press F for a Random Weapon [Cost: 950]"
                    Button3.Text.Value = "Press F for a Random Weapon [Cost: 950]"
                end
            end
        end
        DB = false
    end
    wait(0.1)
    Activate = nil
    Button1.Activate.Value = nil
    Button2.Activate.Value = nil
    Button3.Activate.Value = nil
end
Button1.Activate.Changed:connect(onActivated)
Button2.Activate.Changed:connect(onActivated)
Button3.Activate.Changed:connect(onActivated)

Answer this question