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

UNANSWERED Weapon Class Gui Help?

Asked by
22To 70
9 years ago

I made this weapon class gui but i want to add to it that classes 2- 6 wont be able to be clicked unles they have the level needed..meaning that what ever there level is in leaderboard it will unlock.. like say class 2 needs level 4 to be able to be clicked in the frame they are all name class 1,class2, class 3 and so on

Here it is


player = script.Parent.Parent.Parent backpack = player.Backpack function chooseClass(class) for i, v in pairs(backpack:GetChildren()) do v:remove() end for i, v in pairs(class:GetChildren()) do if v:IsA("Tool") then v:clone().Parent = backpack elseif v:IsA("HopperBin") then v:clone().Parent = backpack end end script.Parent.Main.Visible = false --no new class for a little bit wait(600000) script.Parent.Main.Visible = true --allow to pick a different class end for i, v in pairs(script.Parent.Main:GetChildren()) do v.MouseButton1Up:connect(function () chooseClass(v) end) end
0
This script is very strange... I only don't understand what's happening in your generic loop on line 18, I don't think that would even work... All you'll need to do is check where the level is stored to view the value and if it's not = to it, do nothing alphawolvess 1784 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

Between lines 4 and 5 (or in line 19 before you call chooseClass(v)) you need to check the local player's value (probably in player.leaderstats .Rank.Value) for the proper value.

You will probably want to set up a table to keep track of the level requirements, like this:

levelRequirements = {1, 2, 4, 10, 20, 100} --level required for class1, class2, etc

Between lines 4 and 5 put this:

    local classNum = tonumber(class.Name:sub(6))
    if player.leaderstats.Rank.Value < levelRequirements[classNum] then
        --do something to show the player that they don't have the level for this class
        return
    end

(Don't forget to change player.leaderstats.Rank.Value to reflect whatever you've got setup in your game)

0
thanks but how do i set up the table and make it work out with the gui? 22To 70 — 9y
0
Use the 'levelRequirements' line; put it anywhere before line 4 (line 4 in your original script) chess123mate 5873 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

It's because you're making it wait 600000 SECONDS?! (or almost 7 days).. In other words you pause the script (thread, more precisely) for that much time.

Anyway, why do you need wait 7 days?!

If you really have a reason to, here are a bunch of ways to fix it

1. Use a separate thread using coroutines

-- Examples
function chooseClass(class)
    coroutine.resume(coroutine.create(function() -- THIS
        -- ............
    end))
end

function chooseClass(class)
    coroutine.wrap(function() -- THIS
        -- ............
    end)()
end

2. Use a separate thread using the spawn function

-- Examples
function chooseClass(class)
    spawn(function() -- THIS
        -- ............
    end)
end

-- ... OR
for i, v in pairs(script.Parent.Main:GetChildren()) do
    v.MouseButton1Up:connect(function ()
        spawn(function() -- THIS
            chooseClass(v)
        end)
    end)
end

3. Use the delay function

Instead of..

script.Parent.Main.Visible = true
wait(600000)

Do..

delay(600000, function()
    script.Parent.Main.Visible = true
end)
0
dude this still wont work with the type im talking about.. i mean like for classes 2 - 6 i want it to be non clickable unless they have the certain amount of rank needed in the leaderboard 22To 70 — 9y
0
Keep in mind that the wait won't be consistent. You will need to use datastore to allow the user to pick a class weekly. Lacryma 548 — 9y

Answer this question