Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function ExecuteEvolveLoading()
- local currentevolvelevel = curevolvelvl
- local curevolve = ""
- function LoadEv(name)
- curevolve = name
- script.Parent.Evolves.pname.Text = name
- script.Parent.Evolves.needs.Text = "Needs:\n"
- for _, i in pairs(script.Parent.Evolves:GetChildren()) do if i:IsA'TextButton' and i.Name ~= "Exit" and i.Name ~= "evolve" then
- i.BorderSizePixel = 3
- i.ZIndex = 3
- if i.Name == name then
- i.BorderSizePixel = 0
- i.ZIndex = 2
- end
- end end
- local decoded = nil
- if curdir:FindFirstChild("Evolves") then
- if curdir.Evolves:FindFirstChild(curevolve) then
- if curdir.Evolves[curevolve]:FindFirstChild("Need") then
- decoded = mod(curdir.Evolves[curevolve].Need.Value)
- end
- end
- else
- if curdir:FindFirstChild(curevolve) then
- if curdir[curevolve]:FindFirstChild("Need") then
- decoded = mod(curdir[curevolve].Need.Value)
- end
- end
- end
- if decoded ~= nil then
- for _, i in pairs(decoded) do
- if i[1] == "LVL" then
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. i[2] .. " Level"
- elseif i[1] == "C" then
- for id, v in pairs(mod2(i[2])) do
- if id ~= 1 then
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. " or "
- end
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. v .. " x" .. i[3]
- end
- elseif i[1] == "ORLVL" then
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. "OR\n" .. i[2] .. " Level"
- elseif i[1] == "OR" then
- for id, v in pairs(mod2(i[2])) do
- if id ~= 1 then
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. " or "
- else
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. "OR\n"
- end
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. v .. " x" .. i[3]
- end
- elseif i[1] == "T" then
- for id, v in pairs(mod2(i[2])) do
- if id ~= 1 then
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. " or "
- end
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. v .. " x" .. i[3]
- end
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. " (will be taken)"
- elseif i[1] == "DAY" then
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. "Day needed"
- elseif i[1] == "NIGHT" then
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. "Night needed"
- end
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. "\n"
- end
- else
- script.Parent.Evolves.needs.Text = script.Parent.Evolves.needs.Text .. "No needs"
- end
- end
- local debounce = true
- script.Parent.Evolves.evolve.MouseButton1Click:connect(function()
- if debounce == true then
- debounce = false
- -- EVOLVING FUNCTION
- if currentevolvelevel == curevolvelvl and curevolve ~= nil and curevolve ~= "" then
- local canevolve = true
- local decoded = nil
- local mega = false
- local randback = false
- if curevolve ~= "Random" and curevolve ~= "Back" then
- if curdir:FindFirstChild("Evolves") then
- if curdir.Evolves:FindFirstChild(curevolve) then
- if curdir.Evolves[curevolve]:FindFirstChild("MegaEvolution") then
- mega = true
- end
- if curdir.Evolves[curevolve]:FindFirstChild("Need") then
- decoded = mod(curdir.Evolves[curevolve].Need.Value)
- end
- end
- else
- if curdir:FindFirstChild(curevolve) then
- if curdir[curevolve]:FindFirstChild("MegaEvolution") then
- mega = true
- end
- if curdir[curevolve]:FindFirstChild("Need") then
- decoded = mod(curdir[curevolve].Need.Value)
- end
- end
- end
- if decoded ~= nil then
- for _, i in pairs(decoded) do
- if i[1] == "LVL" then
- if CallServer("GetLVL") < tonumber(i[2]) then
- canevolve = false
- end
- elseif i[1] == "C" then
- local passed = false
- for id, v in pairs(mod2(i[2])) do
- if Stats.GetStat(v) >= tonumber(i[3]) then
- passed = true
- end
- end
- if not passed then canevolve = false end
- elseif i[1] == "ORLVL" then
- if CallServer("GetLVL") < tonumber(i[2]) then
- canevolve = canevolve or false
- end
- elseif i[1] == "OR" then
- local passed = false
- for id, v in pairs(mod2(i[2])) do
- if Stats.GetStat(v) >= tonumber(i[3]) then
- passed = true
- end
- end
- canevolve = canevolve or passed -- resets to true if it succeeds
- elseif i[1] == "T" then
- local passed = false
- for id, v in pairs(mod2(i[2])) do
- if Stats.GetStat(v) >= tonumber(i[3]) then
- passed = true
- end
- end
- if not passed then canevolve = false end
- elseif i[1] == "DAY" then
- if CallServer("DayNight") ~= "D" then
- canevolve = false
- end
- elseif i[1] == "NIGHT" then
- if CallServer("DayNight") ~= "N" then
- canevolve = false
- end
- end
- end
- end
- elseif curevolve == "Back" then
- if curdir:FindFirstChild("Evolves") then
- if curdir.Evolves:FindFirstChild("Random") then
- randback = true
- end
- else
- if curdir:FindFirstChild("Random") then
- randback = true
- end
- end
- end
- -- EVOLVE REQUIREMENTS CHECK
- if canevolve then
- local evolved = nil
- if not mega then
- if curevolve == "Back" then
- if randback then
- evolved = CallServer("Evolve", curdir.Name)
- else
- evolved = CallServer("Evolve", FindPreviousPokemon(curdir).Name)
- end
- else
- evolved = CallServer("Evolve", curevolve)
- end
- else
- evolved = CallServer("MegaEvolve", curevolve)
- end
- if evolved then
- -- TAKING ITEMS
- if curevolve ~= "Random" and curevolve ~= "Back" then
- if decoded ~= nil then
- for _, i in pairs(decoded) do
- if i[1] == "T" then
- for id, v in pairs(mod2(i[2])) do
- if Stats.GetStat(v) >= tonumber(i[3]) then
- CallServer("ChangeStat", v, Stats.GetStat(v) - tonumber(i[3]))
- break
- end
- end
- end
- end
- end
- end
- if curevolve ~= "Random" and curevolve ~= "Back" then
- script.Parent.InfoBar:FindFirstChild("Name").Text = curevolve
- elseif curevolve == "Back" and not randback then
- script.Parent.InfoBar:FindFirstChild("Name").Text = FindPreviousPokemon(curdir).Name
- end
- script.Parent.Evolves:TweenPosition(UDim2.new(1.5, 0, 0.1, 0), "Out", "Quad", 1, true)
- script.Parent.Inventory:TweenPosition(UDim2.new(1.5, 0, 0.1, 0), "Out", "Quad", 1, true)
- openedframe = ""
- curevolvelvl = curevolvelvl + 1
- if curevolve ~= "Random" and curevolve ~= "Back" and not mega then
- if curdir:FindFirstChild("Evolves") then
- curdir = curdir.Evolves:FindFirstChild(curevolve)
- elseif curdir:FindFirstChild(curevolve) then
- curdir = curdir:FindFirstChild(curevolve)
- end
- elseif curevolve == "Back" and not randback then
- curdir = FindPreviousPokemon(curdir)
- end
- script.Parent.Evolves.needs.Text = "Needs:"
- script.Parent.Evolves.pname.Text = "Choose an evolution!"
- if curevolve == "Random" then
- alreadyevolved = true
- elseif curevolve == "Back" and randback then
- alreadyevolved = false
- end
- local tl = nil
- if mega then
- tl = Instance.new("TextLabel", script.Parent)
- tl.Position = UDim2.new(0.7, 0, 1, 0)
- tl.Size = UDim2.new(0.3, 0, 0.05, 0)
- tl.BackgroundTransparency = 1
- tl.TextColor3 = Color3.new(1,1,1)
- tl.TextScaled = true
- tl.Text = "De-evolving in 180 seconds!"
- tl:TweenPosition(UDim2.new(0.7, 0, 0.95, 0), "Out", "Quad", 1, true)
- end
- local towait = mega == true and 180 or 10
- while towait ~= 0 do
- if tl then tl.Text = "De-evolving in "..tostring(towait).." seconds!" end
- script.Parent.InfoBar.Evolve.Text = "Wait "..tostring(mega and towait + 120 or towait).." seconds"
- towait = towait - 1
- wait(1)
- end
- if tl then tl:TweenPosition(UDim2.new(0.7, 0, 1, 0), "Out", "Quad", 1, true, function() tl:Destroy() end) end
- if mega then
- CallServer("Evolve", curdir.Name, 1)
- script.Parent.InfoBar:FindFirstChild("Name").Text = curdir.Name
- towait = 120
- while towait ~= 0 do
- script.Parent.InfoBar.Evolve.Text = "Wait "..tostring(towait).." seconds"
- towait = towait - 1
- wait(1)
- end
- end
- script.Parent.InfoBar.Evolve.Text = "Evolve"
- ExecuteEvolveLoading()
- end
- end
- end
- debounce = true
- end
- end)
- -- GETTING LIST OF EVOS
- local tab = {} -- EVOS
- if curdir:FindFirstChild("Evolves") then
- for _, i in pairs(curdir.Evolves:GetChildren()) do
- if i.Name == "Random" then
- table.insert(tab, {Name = "Random"})
- if alreadyevolved then
- table.insert(tab, {Name = "Back"})
- end
- else
- table.insert(tab, i)
- end
- end
- else
- for _, i in pairs(curdir:GetChildren()) do
- if i:IsA'Folder' and i.Name ~= "SetStatsOnSpawn" and i.Name ~= "Weapons" and i.Name ~= "Spawns" then
- if i.Name == "Random" then
- table.insert(tab, {Name = "Random"})
- if alreadyevolved then
- table.insert(tab, {Name = "Back"})
- end
- else
- table.insert(tab, i)
- end
- end
- end
- end
- for _, i in pairs(script.Parent.Evolves:GetChildren()) do if i:IsA'TextButton' and i.Name ~= "evolve" and i.Name ~= "Exit" then i:Destroy() end end
- local X = 0
- if #tab ~= 0 then X = 1 / #tab end
- for num, i in pairs(tab) do
- local but = Instance.new("TextButton", script.Parent.Evolves)
- but.Name = i.Name
- but.Transparency = 0
- but.BackgroundColor3 = Color3.new(65/255, 65/255, 65/255)
- but.BorderSizePixel = 3
- but.BorderColor3 = Color3.new(0, 0, 0)
- but.Font = Enum.Font.SourceSansBold
- but.Text = i.Name
- but.TextColor3 = Color3.new(1, 1, 1)
- but.TextScaled = true
- but.Size = UDim2.new(X, 0, 0.1, 0)
- but.Position = UDim2.new((num - 1) * X, 0, 0, 0)
- but.ZIndex = 2
- -- FUNCTIONS
- but.MouseButton1Click:connect(function() LoadEv(i.Name) end)
- end
- if tab[1] ~= nil then
- LoadEv(tab[1].Name)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement