Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local ServerStorage = game:GetService("ServerStorage")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local MarketPlaceService = game:GetService("MarketplaceService")
- local DataStoreService = game:GetService("DataStoreService")
- local DataStore = DataStoreService:GetDataStore("EggsSystem1")
- local function PlayerAdded(Player: Player)
- for i, v in pairs(ServerStorage.EggHatchingData:GetChildren()) do
- v:Clone().Parent = Player
- end
- if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 1209923362) then
- Player.Values:FindFirstChild("CanTripleHatch").Value = true
- end
- local Data = DataStore:GetAsync(Player.UserId.."Chaos")
- if Data ~= nil then
- for i, v in pairs(Data) do
- local Val = Instance.new("StringValue", Player.Chaos)
- Val.Name = v
- end
- end
- end
- local function PlayerRemoving(Player: Player)
- local Chaos = {}
- for i, v in pairs(Player.Chaos:GetChildren()) do
- table.insert(Chaos, v.Name)
- end
- DataStore:SetAsync(Player.UserId.."Chaos", Chaos)
- end
- local function ChooseChao(Egg)
- local Chance = math.random(1, 100)
- local Counter = 0
- for _, Chao in pairs(ReplicatedStorage.Chaos[Egg.Name]:GetChildren()) do
- Counter = Counter + Chao.Rarity.Value
- if Chance <= Counter then
- return Chao.Name
- end
- end
- end
- ReplicatedStorage.Remotes.Chaos.HatchServer.OnServerInvoke = function(Player, Egg)
- local EggModel = workspace.Eggs:FindFirstChild(Egg.Name)
- if EggModel ~= nil then
- local Price = EggModel:FindFirstChild("Price")
- local Currency = EggModel:FindFirstChild("Currency").Value
- local NumberPrice = tonumber(Price.Value)
- if tonumber(Player.leaderstats[Currency].Value) >= NumberPrice then
- Player.leaderstats[Currency].Value -= Price.Value
- local ChosenChao = ChooseChao(Egg)
- local Val = Instance.new("StringValue", Player.Chaos)
- Val.Name = ChosenChao
- print(ChosenChao)
- return ChosenChao
- else
- return "Cannot Hatch"
- end
- end
- end
- ReplicatedStorage.Remotes.Chaos.Hatch3Chaos.OnServerInvoke = function(Player, Egg)
- if Player.Values.CanTripleHatch.Value == true then
- local EggModel = workspace.Eggs:FindFirstChild(Egg.Name)
- if EggModel ~= nil then
- local Price = EggModel:FindFirstChild("Price")
- local Currency = EggModel:FindFirstChild("Currency").Value
- local NumberPrice = tonumber(Price.Value)
- if tonumber(Player.leaderstats[Currency].Value) >= NumberPrice * 3 then
- Player.leaderstats[Currency].Value -= NumberPrice * 3
- local ChosenChao = ChooseChao(Egg)
- local ChosenChao2 = ChooseChao(Egg)
- local ChosenChao3 = ChooseChao(Egg)
- local Val = Instance.new("StringValue", Player.Chaos)
- Val.Name = ChosenChao
- local Val2 = Instance.new("StringValue", Player.Chaos)
- Val2.Name = ChosenChao2
- local Val3 = Instance.new("StringValue", Player.Chaos)
- Val3.Name = ChosenChao3
- print(ChosenChao)
- print(ChosenChao2)
- print(ChosenChao3)
- return ChosenChao, ChosenChao2, ChosenChao3
- else
- return false
- end
- end
- else
- return "The Player Does Not Own The Gamepass"
- end
- end
- ReplicatedStorage.Remotes.Chaos.EquipChao.OnServerInvoke = function(Player, ChaoName)
- local EquippedNumberOfChaos = #workspace.PlayerChaos:FindFirstChild(Player.Name):GetChildren()
- if (EquippedNumberOfChaos + 1) <= Player.Values.MaxChaosEquipped.Value then
- local ClonedChao = ReplicatedStorage.Chaos:FindFirstChild(ChaoName, true):Clone()
- ClonedChao.Parent = workspace.PlayerChaos:FindFirstChild(Player.Name)
- Player.RingMultiplier.Value += ClonedChao.RingMultiplier.Value
- return "Equip"
- elseif (EquippedNumberOfChaos + 1) >= Player.Values.MaxChaosEquipped.Value then
- return "Cannot Equip"
- end
- end
- ReplicatedStorage.Remotes.Chaos.UnequipChao.OnServerInvoke = function(Player, ChaoName)
- local Chao = workspace.PlayerChaos:FindFirstChild(Player.Name):FindFirstChild(ChaoName)
- if Player.RingMultiplier.Value == Chao.RingMultiplier.Value then
- Player.RingMultiplier.Value = 1
- else
- Player.RingMultiplier.Value -= Chao.RingMultiplier.Value
- end
- Chao:Destroy()
- return true
- end
- ReplicatedStorage.Remotes.Chaos.DeleteChao.OnServerEvent:Connect(function(Player, ChaoName)
- if Player.Chaos:FindFirstChild(ChaoName) then
- Player.Chaos:FindFirstChild(ChaoName):Destroy()
- local Chao = workspace.PlayerChaos:FindFirstChild(Player.Name):FindFirstChild(ChaoName)
- if Chao ~= nil then
- if Player.RingMultiplier.Value == Chao.RingMultiplier.Value then
- Player.RingMultiplier.Value = 1
- else
- Player.RingMultiplier.Value -= Chao.RingMultiplier.Value
- end
- Chao:Destroy()
- end
- end
- end)
- MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player: Instance, GamepassId: number, WasPurchased: boolean)
- if GamepassId == 1209923362 and WasPurchased == true then
- Player.Values:FindFirstChild("CanTripleHatch").Value = true
- end
- end)
- Players.PlayerAdded:Connect(PlayerAdded)
- Players.PlayerRemoving:Connect(PlayerRemoving)
- for i, Player in pairs(Players:GetPlayers()) do
- PlayerAdded(Player)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement