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
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)
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
-- Examples function chooseClass(class) coroutine.resume(coroutine.create(function() -- THIS -- ............ end)) end function chooseClass(class) coroutine.wrap(function() -- THIS -- ............ end)() end
-- 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
Instead of..
script.Parent.Main.Visible = true wait(600000)
Do..
delay(600000, function() script.Parent.Main.Visible = true end)