Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = Workspace.VERSION.Value
- local service = game:GetService("DataStoreService"):GetDataStore("ForeverDevStats" .. version)
- function script.Parent.AwardAchievement.OnInvoke(player, award)
- local frame = game.ReplicatedStorage.Achievement:clone()
- frame.Parent = player.PlayerGui.ScreenGui
- frame.Award.Text = award
- service:SetAsync(player.userId .. award, true)
- end
- function script.Parent.GetData.OnServerInvoke(player, dataName, returnInstance)
- if game.ServerStorage:FindFirstChild(player.Name .. "Data") then
- if returnInstance then
- return game.ServerStorage[player.Name .. "Data"][dataName]
- end
- return game.ServerStorage[player.Name .. "Data"][dataName].Value
- end
- return false
- end
- function script.Parent.ChangeData.OnServerInvoke(player, dataName, value)
- if game.ServerStorage:FindFirstChild(player.Name .. "Data") then
- game.ServerStorage[player.Name .. "Data"][dataName].Value = value
- return game.ServerStorage[player.Name .. "Data"][dataName].Value
- end
- return false
- end
- function script.Parent.AffectPlayer.OnInvoke(player, object)
- print(player.Name)
- if object:IsA("BoolValue") and object.Name:find("ACH") then
- local ach = player.PlayerGui.ScreenGui.Menu.Current.Achievements.Collection[object.Name]
- if object.Value then
- ach.CurrentImage.Value = ach.Images.Earned.Value
- else
- ach.CurrentImage.Value = ach.Images.NotEarned.Value
- end
- game:GetService("PointsService"):AwardPoints(player.userId, 100)
- end
- end
- local version = Workspace.VERSION.Value
- local storage = game.ServerStorage
- local service = game:GetService("DataStoreService"):GetDataStore("ForeverDevStats" .. version)
- local default = {
- cash = 10,
- ach_thousandcash = false
- }
- local comma = function(number)
- repeat number, count = tostring(number):gsub("^(%d+)(%d%d%d)", "%1,%2") until count == 0
- return number
- end
- game.Players.PlayerAdded:connect(function(player)
- local data;
- local data = storage.Data:clone()
- data.Parent = storage
- data.Name = player.Name .. "Data"
- local screen = player.PlayerGui:WaitForChild("ScreenGui")
- for _, store in ipairs(data:GetChildren()) do
- store.Changed:connect(function(value)
- if store:FindFirstChild("DisplayedOnScreen") then
- screen[store.Name].Output.Text = screen[store.Name].StringOutput.Value:gsub("VALUE", comma(value))
- end
- if store:FindFirstChild("Achievement") then
- Workspace.Functions.AffectPlayer:Invoke(player, store)
- if not service:GetAsync(player.userId .. tostring(store.AchievementKey.Value)) and value then
- screen.Menu.Current.Achievements.Collection[store.Name].Achieved.Value = true
- Workspace.Functions.AwardAchievement:Invoke(player, store.AchievementKey.Value)
- end
- end
- end)
- store.Value = service:GetAsync(tostring(player.userId) .. store.Name:lower()) or default[store.Name:lower()]
- end
- player.CharacterAdded:connect(function()
- --eww, incoming disgusting code. changing a value to the same value doesn't execute the .Changed event, sadly
- coroutine.wrap(function()
- wait(2)
- for _, store in ipairs(data:GetChildren()) do
- if store:IsA("NumberValue") then
- store.Value = store.Value + 1
- store.Value = store.Value - 1
- elseif store:IsA("BoolValue") then
- store.Value = not store.Value
- store.Value = not store.Value
- end
- end
- end)()
- end)
- end)
- game.Players.PlayerRemoving:connect(function(player)
- local data = storage:FindFirstChild(player.Name .. "Data")
- if data then
- for _, store in ipairs(data:GetChildren()) do
- service:SetAsync(tostring(player.userId) .. store.Name:lower(), store.Value)
- end
- end
- end)
- local player = game.Players.LocalPlayer
- local screen = script.Parent
- local mouse = player:GetMouse()
- local movements = {}
- for _, object in ipairs(screen:GetChildren()) do
- if object:IsA("Frame") then
- movements[object.Name] = {pos = object.Position, direction = object.Direction.Value}
- end
- end
- local menu = {
- body = screen:WaitForChild("Menu"),
- current = screen.Menu:WaitForChild("Current"),
- changeView = function(self, mode)
- for _, v in ipairs(self.body.Current:GetChildren()) do
- if v:IsA("Frame") then
- if v.Name:lower() ~= mode then
- v:TweenPosition(UDim2.new(0, 0, -1, -1), "Out", "Quad", 1, true)
- else
- coroutine.wrap(function()
- wait(1)
- v:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quad", 1, true)
- end)()
- end
- end
- end
- self.body.Title.Text = mode == "main" and "Menu" or mode:gsub("^.", function(match) return match:upper() end)
- end,
- openOrClose = function()
- local moved;
- local menu = screen.Menu
- if menu.Position == UDim2.new(0.5, -240, 1, 20) then
- moved = "open"
- menu:TweenPosition(UDim2.new(0.5, -240, 0.5, -200), "Out", "Back", 1)
- coroutine.wrap(function()
- wait(2)
- Workspace.Functions.ChangeData:InvokeServer("ACH_MenuExplorer", true)
- end)()
- elseif menu.Position == UDim2.new(0.5, -240, 0.5, -200) then
- moved = "close"
- menu:TweenPosition(UDim2.new(0.5, -240, 1, 20), "Out", "Quad", 1)
- end
- if moved then
- for _, object in ipairs(screen:GetChildren()) do
- if object:IsA("Frame") and object.Name ~= "Achievement" and object ~= menu then
- object:TweenPosition(movements[object.Name].pos + UDim2.new(0, moved == "open" and (movements[object.Name].direction == "left" and -object.Size.X.Offset or object.Size.X.Offset) or movements[object.Name].pos.X.Offset, 0, 0), "Out", "Quad", 0.9, true)
- end
- end
- end
- end
- }
- local hoverEvents = function(object, leave, enter, down)
- local save = object.Position
- object.MouseEnter:connect(function()
- object.Image = "rbxassetid://" .. enter
- object:TweenPosition(save - UDim2.new(0, 0, 0, 5), "Out", "Quad", 0.5, true)
- end)
- object.MouseLeave:connect(function()
- object.Image = "rbxassetid://" .. leave
- object:TweenPosition(save, "Out", "Bounce", 0.5, true)
- end)
- object.MouseButton1Down:connect(function()
- object.Image = "rbxassetid://" .. down
- end)
- object.MouseButton1Up:connect(function()
- object.Image = "rbxassetid://" .. leave
- object:TweenPosition(save, "Out", "Quad", 0.5, true)
- end)
- end
- local newClickEvent = function(class, object, ...)
- local args = {...}
- if class == "close" then
- object.MouseButton1Click:connect(function()
- menu:openOrClose()
- menu:changeView("main")
- end)
- elseif class == "view" then
- object.MouseButton1Click:connect(function()
- menu:changeView(args[1])
- end)
- end
- end
- mouse.KeyDown:connect(function(key)
- if key:lower() == "p" then
- menu:openOrClose()
- end
- end)
- hoverEvents(menu.current.Main.Achievements, "180893368", "180737861", "180737435")
- menu.current.Main.Achievements.MouseButton1Click:connect(function()
- menu:changeView("achievements")
- end)
- hoverEvents(menu.current.Achievements.Close, "180818606", "180823928", "180824362")
- newClickEvent("close", menu.current.Achievements.Close)
- hoverEvents(menu.current.Achievements.Back, "180826525", "180827456", "180827481")
- newClickEvent("view", menu.current.Achievements.Back, "main")
- local pos = {}
- repeat wait() until #script.Parent:GetChildren() >= 3
- for _, label in ipairs(script.Parent:GetChildren()) do
- if label:IsA("ImageLabel") then
- label.Image = "rbxassetid://" .. (Workspace.Functions.GetData:InvokeServer(label.Name) and label.Images.Earned.Value or label.Images.NotEarned.Value)
- label:WaitForChild("CurrentImage").Changed:connect(function(value)
- label.Image = "rbxassetid://" .. label.Images.Earned.Value
- end)
- pos[label.Name] = {position = label.Position, size = label.Size}
- label.MouseEnter:connect(function()
- label:TweenSizeAndPosition(pos[label.Name].size + UDim2.new(0, 4, 0, 4), pos[label.Name].position - UDim2.new(0, 2, 0, 2), "Out", "Linear", 0.2, true)
- script.Parent.Parent:WaitForChild("Display").Text = (Workspace.Functions.GetData:InvokeServer(label.Name) and "| ACHIEVED | " or "| NOT ACHIEVED | ") .. "\n" .. label.Display.Value:gsub("LINE", "\n")
- end)
- label.MouseLeave:connect(function()
- label:TweenSizeAndPosition(pos[label.Name].size, pos[label.Name].position, "Out", "Linear", 0.2, true)
- script.Parent.Parent:WaitForChild("Display").Text = ""
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment