Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 1 скрипт в лобби локальный --
- wait(4)
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local CurrencyRemote = ReplicatedStorage:WaitForChild("GiveCoinsRemote")
- local TowerRemote = ReplicatedStorage:WaitForChild("TowerRemote")
- local CrateRemote = ReplicatedStorage:WaitForChild("CratesRemote")
- local battlePassRemote = ReplicatedStorage:WaitForChild("BattlePassRemote")
- local UserInputService = game:GetService("UserInputService")
- local currentTier = nil
- local tiers = {
- {Name = "Tier 0", Reward = 0,Type = "Cash", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 0, TierValue = 0, Image = ""},
- {Name = "Tier 1", Reward = 100,Type = "Cash", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 0, TierValue = 1, Image = "rbxassetid://128156575674902"},
- {Name = "Tier 2", Reward = 200,Type = "Cash", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 20, TierValue = 2, Image = "rbxassetid://128156575674902"},
- {Name = "Tier 3", Reward = 300,Type = "Cash", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 40, TierValue = 3, Image = "rbxassetid://111033659398113"},
- {Name = "Tier 4", Reward = 25,Type = "Gems", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 65, TierValue = 4, Image = "rbxassetid://101633758990575"},
- {Name = "Tier 5", Reward = 45,Type = "Gems", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 90, TierValue = 5, Image = "rbxassetid://101633758990575"},
- {Name = "Tier 6", Reward = "Mythic Tower 1", Type = "Tower", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 120, TierValue = 6, Image = "rbxassetid://80469276367256"},
- {Name = "Tier 7", Reward = 250,Type = "Cash", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 150, TierValue = 7, Image = "rbxassetid://111033659398113"},
- {Name = "Tier 8", Reward = 450,Type = "Cash", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 180, TierValue = 8, Image = "rbxassetid://111033659398113"},
- {Name = "Tier 9", Reward = 50,Type = "Gems", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 200, TierValue = 9, Image = "rbxassetid://101633758990575"},
- {Name = "Tier 10", Reward = 99,Type = "Gems", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 230, TierValue = 10, Image = "rbxassetid://101633758990575"},
- {Name = "Tier 11", Reward = 299,Type = "Cash", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 350, TierValue = 11, Image = "rbxassetid://111033659398113"},
- {Name = "Tier 12", Reward = "Example Crate", Type = "Crate", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 500, TierValue = 12, Image = "rbxassetid://133625418876443"},
- {Name = "Tier 13", Reward = "", Type = "", XP = ReplicatedStorage:WaitForChild("Game"):WaitForChild("XP").Value, Need = 0, TierValue = 0, Image = ""}
- }
- local frame = script.Parent.Parent.ScrollingFrame
- local completedTiers = {}
- local function updateUI()
- for i, tier in ipairs(tiers) do
- local nexttier = tiers[i+1]
- local tierLabel = frame:FindFirstChild(tier.Name) or Instance.new("Frame")
- local uistroke = Instance.new("UIStroke")
- local uicorner = Instance.new("UICorner")
- local imageframe = Instance.new("ImageLabel")
- uistroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
- uistroke.Thickness = 2
- uistroke.Parent = tierLabel
- uicorner.CornerRadius = UDim.new(0, 4.25)
- uicorner.Parent = tierLabel
- tierLabel.Name = tier.Name
- tierLabel.Size = UDim2.new(0, 125, 0, 125)
- tierLabel.Position = UDim2.new(0, 0, 0, (i - 1) * 60)
- tierLabel.BackgroundColor3 = Color3.new(0, 0.666667, 1)
- imageframe.BackgroundTransparency = 1
- imageframe.Image = tier.Image
- imageframe.Size = UDim2.new(0, 80, 0, 80)
- imageframe.Position = UDim2.new(0.200, 0,0.000, 0)
- imageframe.Image = tier.Image
- imageframe.Parent = tierLabel
- tierLabel.Parent = frame
- local claimButton = tierLabel:FindFirstChild("ClaimButton") or Instance.new("TextButton")
- local buttonuistroke = Instance.new("UIStroke")
- local textuistroke = Instance.new("UIStroke")
- local buttonuicorner = Instance.new("UICorner")
- textuistroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Contextual
- textuistroke.Thickness = 2.5
- textuistroke.Parent = claimButton
- buttonuicorner.CornerRadius = UDim.new(0, 4.25)
- buttonuicorner.Parent = claimButton
- claimButton.Name = "ClaimButton"
- claimButton.Text = "Claim"
- claimButton.BackgroundColor3 = Color3.new(0, 1, 0)
- claimButton.TextColor3 = Color3.new(1, 1, 1)
- claimButton.Font = Enum.Font.FredokaOne
- claimButton.TextScaled = true
- claimButton.BackgroundTransparency = 0
- claimButton.Position = UDim2.new(0.001, 0,0.745, 0)
- claimButton.Size = UDim2.new(1.000, 0,0.256, 0)
- claimButton.Parent = tierLabel
- if table.find(completedTiers, tier.Name) then
- if not currentTier or tier.TierValue > currentTier.TierValue then
- currentTier = tier
- frame.Parent.Info.Tier.Text = currentTier.Name
- frame.Parent.ImageBox.ImageLabel.Image = currentTier.Image
- frame.Parent.Info.XP.Text = currentTier.XP .. " / " .. currentTier.Need
- frame.Parent.Info["Next Reward"].Text = "Next Reward :" .. nexttier.Reward .." Type : ".. nexttier.Type
- claimButton.Visible = false
- else
- claimButton.Visible = true
- end
- end
- if UserInputService.TouchEnabled then
- tierLabel.Size = UDim2.new(0, 75, 0, 75)
- tierLabel.Position = UDim2.new(0, 0, 0, (i - 1) * 90)
- imageframe.Size = UDim2.new(0, 50, 0, 50)
- imageframe.Position = UDim2.new(0.185, 0,0.000, 0)
- end
- claimButton.MouseButton1Click:Connect(function()
- local Type = tier.Type
- local reward = tier.Reward
- if tier.XP >= tier.Need then
- if tier.Type == "Cash" or tier.Type == "Gems" then
- CurrencyRemote:FireServer(tier.Reward, Type)
- print(tier.Name, tier.Reward)
- game.ReplicatedStorage:WaitForChild("Game"):WaitForChild("Events"):WaitForChild("UpdateMoneyClient"):Fire()
- game.ReplicatedStorage:WaitForChild("Game"):WaitForChild("Events"):WaitForChild("UpdateMoneyClient"):Fire("Cash")
- game.ReplicatedStorage:WaitForChild("Game"):WaitForChild("Events"):WaitForChild("UpdateMoneyClient"):Fire("Gems")
- end
- if tier.Type == "Tower" then
- TowerRemote:FireServer(reward)
- print(tier.Name, tier.Reward)
- end
- if tier.Type == "Crate" then
- CrateRemote:FireServer(reward)
- print(tier.Name, tier.Reward)
- end
- if not currentTier or tier.TierValue > currentTier.TierValue then
- currentTier = tier
- frame.Parent.Info.Tier.Text = currentTier.Name
- frame.Parent.ImageBox.ImageLabel.Image = currentTier.Image
- frame.Parent.Info["Next Reward"].Text = "Next Reward :" .. nexttier.Reward .." Type : ".. nexttier.Type
- frame.Parent.Info.XP.Text = currentTier.XP .. "/".. currentTier.Need
- end
- table.insert(completedTiers, tier.Name)
- battlePassRemote:FireServer("SaveProgress", completedTiers)
- claimButton.Visible = false
- script.Parent.Parent.Got.Visible = true
- script.Parent.Parent.Got.Text = "✅ You Get " .. tier.Reward .. " " .. tier.Type .." In ".. tier.Name .. " ✅"
- task.wait(2)
- script.Parent.Parent.Got.Visible = false
- else
- print("Not Enough Xp To Claim Tier")
- claimButton.Text = "Not Enough Xp"
- claimButton.BackgroundColor3 = Color3.new(0.262745, 0.262745, 0.262745)
- task.wait(2)
- claimButton.Text = "Claim"
- claimButton.BackgroundColor3 = Color3.new(0, 1, 0)
- end
- end)
- if tier.Name == "Tier 0" then
- tierLabel.Visible = false
- end
- if tier.Name == "Tier 13" then
- tierLabel.Visible = false
- end
- end
- end
- local function loadProgress()
- battlePassRemote:FireServer("LoadProgress")
- end
- battlePassRemote.OnClientEvent:Connect(function(completed)
- completedTiers = completed or {}
- updateUI()
- end)
- loadProgress()
- -- 2 скрипт серверный --
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local battlePassRemote = ReplicatedStorage:WaitForChild("BattlePassRemote")
- local DataStoreService = game:GetService("DataStoreService")
- local PlayerDataStore = DataStoreService:GetDataStore("PlayerBattlePassProgress")
- local function loadProgress(player)
- local success, result = pcall(function()
- return PlayerDataStore:GetAsync(player.UserId)
- end)
- if success and result then
- return result
- else
- return {}
- end
- end
- local function saveProgress(player, completedTiers)
- local success, errorMessage = pcall(function()
- PlayerDataStore:SetAsync(player.UserId, completedTiers)
- end)
- if not success then
- warn("Error when saving progress for player " .. player.Name .. ": " .. errorMessage)
- end
- end
- battlePassRemote.OnServerEvent:Connect(function(player, request, data)
- wait(1.5)
- if request == "LoadProgress" then
- local completedTiers = loadProgress(player)
- battlePassRemote:FireClient(player, completedTiers)
- elseif request == "SaveProgress" then
- saveProgress(player, data)
- end
- end)
- game.Players.PlayerAdded:Connect(function(player)
- local completedTiers = loadProgress(player)
- --battlePassRemote:FireClient(player, completedTiers)
- end)
- -- 3 скрипт серверный --
- local PlayerData = require(game:GetService("ServerScriptService").Data)
- local towers = require(game:GetService("ReplicatedStorage"):WaitForChild("Module_Towers"))
- local cratesremote = game.ReplicatedStorage:WaitForChild("CratesRemote")
- local remote = game.ReplicatedStorage:WaitForChild("GiveCoinsRemote")
- local towersremote = game.ReplicatedStorage:WaitForChild("TowerRemote")
- local codegenerator = require(game:GetService("ServerStorage").UniqueCodeGenerator)
- local GameFolder = game:GetService("ReplicatedStorage"):WaitForChild("Game")
- local FuncFolder = GameFolder:WaitForChild("Functions")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local players = game.Players
- players.PlayerAdded:Connect(function(player)
- task.wait(2)
- local function ReceiveData(player)
- local data = PlayerData:ReturnProfile(player)
- if typeof(data) == "table" and data["Data"] then
- print("Found Existing Player Data.")
- data = data["Data"]
- return data
- else
- print("you can`t get a data")
- end
- end
- remote.OnServerEvent:Connect(function(player, Amount, Type)
- local prldata = PlayerData:ReturnProfile(player)
- if typeof(prldata) == "table" and prldata["Data"] then
- prldata = prldata["Data"]
- print("ACTIVATED")
- prldata[Type] = prldata[Type] + Amount
- end
- end)
- towersremote.OnServerEvent:Connect(function(player, reward)
- local prldata = PlayerData:ReturnProfile(player)
- if typeof(prldata) == "table" and prldata["Data"] then
- prldata = prldata["Data"]
- local tower = table.clone(towers[reward])
- tower["UniqueID"] = codegenerator:generateCode()
- table.insert(prldata["Inventory"]["Towers"], tower)
- print("ACTIVATED")
- end
- end)
- cratesremote.OnServerEvent:Connect(function(player, reward)
- local prldata = PlayerData:ReturnProfile(player)
- if typeof(prldata) == "table" and prldata["Data"] then
- prldata = prldata["Data"]
- local cratetogive = {
- ["CrateName"] = reward,
- ["UniqueID"] = codegenerator:generateCode()
- }
- table.insert(prldata["Inventory"]["Crates"], cratetogive)
- print("ACTIVATED")
- end
- end)
- GameFolder:WaitForChild("Events"):WaitForChild("UpdateClientMoney").OnServerEvent:Connect(function(currency)
- PlayerData["Cash"] = FuncFolder:WaitForChild("GetCurrency"):InvokeClient(currency)
- PlayerData["Gems"] = FuncFolder:WaitForChild("GetCurrency"):InvokeClient(currency)
- end)
- while wait(0.25) do
- GameFolder:WaitForChild("Events"):WaitForChild("UpdateMoneyClient"):Fire()
- GameFolder:WaitForChild("Events"):WaitForChild("UpdateMoneyClient"):Fire("Cash")
- GameFolder:WaitForChild("Events"):WaitForChild("UpdateMoneyClient"):Fire("Gems")
- end
- game:GetService("ReplicatedStorage").Game.Functions.GetCurrency.OnServerInvoke = ReceiveData
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement