Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Made by qsenko29
- -- ClientSide Script
- local RS = game:GetService("ReplicatedStorage") -- the actual Service in what we have all the Pets,Events stored and etc.
- local PetsFolder = RS.Pets
- local PetsPurchaseEvent = PetsFolder.PetEvents.PetsPurchase
- local PetsGamepassEvent = PetsFolder.PetEvents.PetGamepass
- local HiddenPetEvent = PetsFolder.PetEvents.HiddenPetEvent
- local MainFrame = script.Parent -- the frame that we will use to loop and get all objects,("instances") from!!!
- local debounce = true -- debounce is not recommended it can be just debounce that means its either true or false but i love setting it to something!!
- local player = game:GetService("Players").LocalPlayer -- thats a easy way of getting the local Player
- local PetValues = player.PetsFolder.Values:GetDescendants() --:GetChildren()
- local BuyFrame = player.PlayerGui:WaitForChild("PetsPurchaseGui").BuyPet
- local BuyButton = player.PlayerGui:WaitForChild("PetsPurchaseGui").BuyPet.Buy
- local CancelButton = player.PlayerGui:WaitForChild("PetsPurchaseGui").BuyPet.Close
- local Pets = PetsFolder.ActualPets:GetChildren()
- local button1 -- gonna disconnect them later:P
- local button2
- local button3
- --print(Pets)
- for i,petCoins in pairs(MainFrame:GetDescendants()) do
- if petCoins:IsA("ImageButton") and petCoins.Name == "PetsButton" then
- for i,Values in pairs(PetValues) do
- if Values:IsA("BoolValue") and Values.Value == true and petCoins.PetIndex.Value == Values.Name then
- if petCoins.PetIndex.Value == Values.Name and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Values.Name then
- petCoins:FindFirstChild("PetPriceCheck").Text = "Equipped"
- print(Values.Name.. " Equipped")
- elseif petCoins.PetIndex.Value == Values.Name and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= Values.Name then
- petCoins.PetPriceCheck.Text = "Owned"
- print(Values.Name.. " Owned")
- elseif Values:IsA("BoolValue") and Values.Value == false then
- if petCoins.PetIndex.Value == Values.Name then
- petCoins.PetPriceCheck.Text = petCoins.PetPriceCheck.Text
- break
- end
- end
- end
- end
- end
- end
- for i,gamepass in pairs(MainFrame:GetDescendants()) do
- if gamepass:IsA("ImageButton") and gamepass.Name == "PetsGamepassButton" then
- if gamepass:FindFirstChild("Gamepass").Value then
- local id = gamepass.Gamepass.Value
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- if ownsGamepass and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= gamepass.PetIndex.Value then
- gamepass.PetPriceCheck.Text = "Owned"
- print("Owned")
- else
- gamepass.PetPriceCheck.Text = gamepass.PetPriceCheck.Text
- end
- if ownsGamepass and player.PetsFolder:FindFirstChild("PetNameCheck").Value == gamepass.PetIndex.Value then
- gamepass.PetPriceCheck.Text = "Equipped"
- print("Equipped")
- else
- gamepass.PetPriceCheck.Text = gamepass.PetPriceCheck.Text
- end
- end
- end
- end
- for i,v in pairs(MainFrame:GetDescendants())do
- if v:IsA("ImageButton") and v.Name == "PetsButton" then
- for i,p in ipairs(PetValues)do
- button1 = v.MouseButton1Down:Connect(function(pet)
- local function RunTest()
- if p:IsA("BoolValue") and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name then -- p.Name ==
- if debounce and player then
- debounce = false
- --local PetIsName = v:FindFirstChild("PetIndex").Value
- if p.Value == false and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name and player.leaderstats.Coins.Value >= v.Price.Value then --and v:FindFirstChild("PetIndex").Value == p.Name-- and p[PetIsName] and p.Name == PetIsName
- local Frame = player:FindFirstChild("PlayerGui"):FindFirstChild("PetsPurchaseGui"):FindFirstChild("BuyPet")
- local FrameInfo = Frame:FindFirstChild("Desc")
- local PetName = v:FindFirstChild("PetIndex").Value
- local PetPrice = v:FindFirstChild("Price").Value
- -- print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")
- -- print(p.Name .. " p.Name - 1st if statement")
- -- print(p.Value)
- FrameInfo.Text = "Are you Sure you want to buy this " .. PetName .. " for " .. PetPrice .. " Coins"
- Frame:TweenPosition(
- UDim2.new(0.499, 0,0.494, 0),-- End Position
- "Out", -- Easing Direction
- "Linear", -- Easing Style
- .5 -- Time in Seconds
- )
- Frame.Visible = true
- wait(.5)
- -- local thisbutton = v
- -- local newfunction = RunTest(thisbutton)
- -- local something = "hi"
- --BuyButton.MouseButton1Down:Connect(function(PetName,PetPrice)
- button2 = BuyButton.MouseButton1Down:Connect(function()
- -- damn it works!!!
- if debounce == false then
- --debounce = false
- local PetName = v:FindFirstChild("PetIndex").Value -- you can comment this!!
- -- print(thisbutton)
- -- print(newfunction)
- --RunTest()
- -- print(PetName)
- --RunTest()
- -- print(PetPrice)
- -- print(RunTest())
- -- print(v:FindFirstChild("PetIndex").Value .. " v - first if statement")
- -- print(p.Name .. " p.Name - 1st if statement")
- -- print(p.Value)
- -- end)
- -- return PetName
- PetsPurchaseEvent:FireServer(p,PetPrice)
- BuyFrame:TweenPosition(
- UDim2.new(0.499, 0,-1, 0),-- End Position
- "Out", -- Easing Direction
- "Linear", -- Easing Style
- .5 -- Time in Seconds
- )
- wait(.5)
- for i,pets in pairs(Pets)do
- if pets:IsA("Model") then
- -- print(pets.Name)
- if p.Value == true then --not player.Character:FindFirstChild(pets.Name)
- if player.PetsFolder:FindFirstChild("PetNameCheck").Value == pets.Name and player.Character:FindFirstChild(pets.Name) then
- -- print("Pet was found in Character")
- v.PetPriceCheck.Text = "Equipped"
- for i,l in pairs(MainFrame:GetDescendants()) do
- if l:IsA("ImageButton") and l.Name == "PetsButton" then
- if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then -- and not v.Name
- if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
- l:FindFirstChild("PetPriceCheck").Text = "Owned"
- -- print("Name Change idk")
- end
- end
- end
- end
- break
- end
- if player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" and not player.Character:FindFirstChild(pets.Name) then
- -- print("Pet was not found in Character")
- v.PetPriceCheck.Text = "Owned"
- break
- end
- end
- end
- end
- button2:Disconnect()
- debounce = true
- end
- end)
- -- debounce = true
- -- return PetName
- end
- if p.Value == false and v:FindFirstChild("PetIndex").Value and v:FindFirstChild("PetIndex").Value == p.Name and player.leaderstats.Coins.Value < v.Price.Value then -- and PetIsName
- v.PetPriceCheck.Text = "Not Enough Coins"
- wait(0.5)
- v.PetPriceCheck.Text = v.Price.Value .. " Coins" -- resets the price to its default per pet
- -- print(p.Name .. " p.Name - second if statement")
- -- print(v:FindFirstChild("PetIndex").Value .. " v - second if statement")
- -- print(p.Value)
- debounce = true
- end
- if p.Value == true then --and v:FindFirstChild("PetIndex").Value == p.Name and player.leaderstats.Coins.Value >= v.Price.Value or player.leaderstats.Coins.Value < v.Price.Value then
- -- print(p.Name .. " p.Name - Third if statement")
- -- print(v:FindFirstChild("PetIndex").Value .. " v - Third if statement")
- -- print(p.Value)
- --v.PetPriceCheck.Text = "Owned"
- PetsPurchaseEvent:FireServer(p)
- -- print("We own the pet firing remote event")
- for i,pets in pairs(Pets)do
- if pets:IsA("Model") then
- -- print(pets.Name)
- if p.Value == true then
- if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == v.PetIndex.Value then --pets.Name
- print("Pet was found in Character")
- v.PetPriceCheck.Text = "Owned" -- it was on Owned
- break
- end
- --[[ if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= v.PetIndex.Value then --pets.Name
- print("Pet was found in Character")
- v.PetPriceCheck.Text = "Equipped" -- it was on Owned
- -- we might need a loop in here
- break
- end--]]
- if v.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value == v.PetIndex.Value then
- print("Pet was not found in Character")
- v.PetPriceCheck.Text = "Equipped"
- for i,gamepass in pairs(MainFrame:GetDescendants()) do
- if gamepass:IsA("ImageButton") and gamepass.Name == "PetsGamepassButton" then
- if gamepass:FindFirstChild("Gamepass").Value then
- local id = gamepass.Gamepass.Value
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- if ownsGamepass then
- gamepass.PetPriceCheck.Text = "Owned"
- else
- gamepass.PetPriceCheck.Text = gamepass.PetPriceCheck.Text
- end
- end
- end
- end
- break
- end
- if v.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= v.PetIndex.Value then
- -- print("Second Remove")
- -- print(v.Name)
- v.PetPriceCheck.Text = "Equipped"
- wait(.1)
- for i,z in pairs(MainFrame:GetDescendants()) do
- if z:IsA("ImageButton") and z.Name == "PetsButton" then
- -- print("Second Remove")
- if z:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value then
- -- print("Second Remove") -- runs to here
- if z.PetPriceCheck.Text == "Owned" or z.PetPriceCheck.Text == "Equipped" and p.Value == true and z:FindFirstChild("PetIndex").Value ~= p.Name then -- it was Equipped -- and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= z:FindFirstChild("PetIndex").Value
- -- print("Second Remove")
- z.PetPriceCheck.Text = "Owned"
- for i,gamepass in pairs(MainFrame:GetDescendants()) do
- if gamepass:IsA("ImageButton") and gamepass.Name == "PetsGamepassButton" then
- -- print("Second Remove")
- if gamepass:FindFirstChild("Gamepass").Value then
- -- print("Second Remove")
- local id = gamepass.Gamepass.Value
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- if ownsGamepass then
- gamepass.PetPriceCheck.Text = "Owned"
- else
- gamepass.PetPriceCheck.Text = gamepass.PetPriceCheck.Text
- end
- end
- end
- end
- end
- end
- end
- end
- wait()
- --[[for i,l in pairs(MainFrame:GetDescendants()) do
- if l:IsA("ImageButton") and l.Name == "PetsButton" then
- if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then -- and not v.Name
- if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
- l:FindFirstChild("PetPriceCheck").Text = "Equipped"--Owned
- print("Name Change idk")
- --break
- end
- end
- end
- end--]]
- break
- end
- --[[ if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" then
- print("Second Equip")
- v.PetPriceCheck.Text = "Equipped"
- for i,l in pairs(MainFrame:GetDescendants()) do
- if l:IsA("ImageButton") and l.Name == "PetsButton" then
- if l:FindFirstChild("PetIndex").Value ~= player.PetsFolder:FindFirstChild("PetNameCheck").Value then
- if l:FindFirstChild("PetPriceCheck").Text == "Equipped" then
- l:FindFirstChild("PetPriceCheck").Text = "Owned"
- print("Name Change idk")
- end
- end
- end
- end
- break
- end
- end
- end
- end --]]
- -- v.PetPriceCheck.Text = v.Price.Value .. " Coins"
- end
- end
- end
- debounce = true
- end
- -- debounce = true
- --print("Making sure you work")
- wait()
- --break
- end
- end
- end
- RunTest()
- button1:Disconnect()
- end)
- end
- end
- if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" then
- --print("not my nigga") -- script will run when player is loaded basically the for loop:)
- button3 = v.MouseButton1Down:Connect(function()
- button3:Disconnect()
- if debounce and player then
- debounce = false
- -- print("not my nigga")
- local id = v:FindFirstChild("Gamepass").Value
- local Name = v:FindFirstChild("PetIndex").Value
- local TextPrice = v:FindFirstChild("PetPriceCheck").Text
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- -- local success, errormessage = pcall(ownsGamepass);
- -- print(id)
- -- print(Name)
- if ownsGamepass then
- -- print("he owns it")
- PetsGamepassEvent:FireServer(id,Name)
- else
- -- print("he doesnt own the gamepass!!")
- PetsGamepassEvent:FireServer(id,Name)
- end
- debounce = true
- end
- end)
- end
- if v:IsA("ImageButton") and v.Name == "PetsHiddenButton" then -- hidden experiment stuff
- --print("not my nigga") -- script will run when player is loaded basically the for loop:)
- v.MouseButton1Down:Connect(function()
- if debounce and player then
- -- if stat bla bla = true then do this bam
- -- print("not my hidden nigga")
- end
- end)
- end
- end
- CancelButton.MouseButton1Down:Connect(function()
- if not debounce and player then
- --debounce = false
- BuyFrame:TweenPosition(
- UDim2.new(0.499, 0,-1, 0),-- End Position
- "Out", -- Easing Direction
- "Linear", -- Easing Style
- .5 -- Time in Seconds
- )
- wait(.5)
- button2:Disconnect()
- BuyFrame.Visible = false
- debounce = true
- end
- end)
- local PetGamepassButton = script.Parent.Frame34.ImageButton.PetsGamepassButton
- PetGamepassButton.MouseButton1Down:Connect(function()
- -- print("Hello")
- if debounce and player then
- debounce = false
- -- print("not my nigga")
- local id = PetGamepassButton:FindFirstChild("Gamepass").Value
- local Name = PetGamepassButton:FindFirstChild("PetIndex").Value
- local TextPrice = PetGamepassButton:FindFirstChild("PetPriceCheck").Text
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- if ownsGamepass then
- -- print("he owns it")
- PetsGamepassEvent:FireServer(id,Name)
- else
- -- print("he doesnt own the gamepass!!")
- PetsGamepassEvent:FireServer(id,Name)
- end
- debounce = true
- end
- end)
- local function onNotifyPlayer(Name,id)
- -- print("Incoming server event...")
- -- print(Name,id)
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- for i,v in pairs(MainFrame:GetDescendants()) do
- if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" and Name == v.PetIndex.Value then
- for i,z in pairs(MainFrame:GetDescendants()) do
- if z:IsA("ImageButton") and z.Name == "PetsButton" then
- for i,pets in pairs(Pets) do
- if pets:IsA("Model") and pets.Name == Name then
- -- print("Hello")
- -- print(pets.Name)
- if ownsGamepass then
- -- print("he owns it") -- this works!!
- if z.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
- -- print("Pet was found in Character")
- z.PetPriceCheck.Text = "Owned" -- it was on Owned
- if player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
- -- print(Name)
- -- print(id)
- -- print(player.PetsFolder:FindFirstChild("PetNameCheck").Value)
- -- print(id == v.Gamepass.Value)
- -- print(v.Gamepass.Value)
- if v.Gamepass.Value == id then
- -- print(Name)
- v.PetPriceCheck.Text = "Equipped"
- end
- end
- return
- end
- --[[ if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
- print("Pet was found in Character")
- if player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
- print(Name)
- if v.Gamepass.Value == id then
- print(Name)
- v.PetPriceCheck.Text = "Owned"
- end
- end
- return
- end --]]
- if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" then
- -- print(Name)
- if v.PetPriceCheck.Text == "Equipped" and v.Gamepass.Value == id then
- -- print(Name)
- -- if v.Gamepass.Value == id then
- -- print(Name)
- v.PetPriceCheck.Text = "Owned"
- break
- -- end
- end
- end
- if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
- if v.PetPriceCheck.Text == "Owned" and v.Gamepass.Value == id then
- -- print(Name) -- tozi red
- v.PetPriceCheck.Text = "Equipped"
- wait()
- for i,namechange in pairs(MainFrame:GetDescendants()) do
- if namechange:IsA("ImageButton") and namechange.Name == "PetsGamepassButton" and Name ~= namechange:FindFirstChild("PetIndex").Value and v.Gamepass.Value == id then
- if namechange:FindFirstChild("PetPriceCheck").Text == "Equipped" and v.Gamepass.Value == id then
- print("idk")
- namechange.PetPriceCheck.Text = "Owned"
- end
- end
- end
- end
- end
- --[[ if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then
- print("idk1")
- if v.PetPriceCheck.Text == "Equipped" then
- print("idk2")
- if v.Gamepass.Value == id then
- print(Name)
- v.PetPriceCheck.Text = "Owned"
- return
- end
- end
- end--]]
- --[[
- if z.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" then
- print("idk1")
- if v.PetPriceCheck.Text == "Owned" then
- print("idk2")
- if v.Gamepass.Value == id then
- print(Name)
- v.PetPriceCheck.Text = "Equipped"
- return
- end
- end
- end--]]
- --[[
- if v.PetPriceCheck.Text == "Owned" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" then --and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name
- v.PetPriceCheck.Text = "Equipped"
- print(Name)
- break
- end--]]
- --[[
- if v.PetPriceCheck.Text == "Equipped" and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name then
- v.PetPriceCheck.Text = "Owned"
- print(Name)
- break
- end--]]
- else
- -- print("he doesnt own the gamepass!!")
- break
- end
- end
- end
- end
- end
- end
- end
- end
- PetsGamepassEvent.OnClientEvent:Connect(onNotifyPlayer)
- -- ServerSide Script
- local DataStoreService = game:GetService("DataStoreService")
- local Petsdata = DataStoreService:GetDataStore("PetShop2")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local MarketplaceService = game:GetService("MarketplaceService")
- local PetsFolder = ReplicatedStorage.Pets
- local PetsPurchaseEvent = PetsFolder.PetEvents.PetsPurchase
- local PetsGamepassEvent = PetsFolder.PetEvents.PetGamepass
- local Pets = PetsFolder.ActualPets:GetChildren()
- local Market
- local debounce = true
- game.Players.PlayerAdded:Connect(function(player)
- --Pets stuff
- local PetsFolder = Instance.new("Folder",player); PetsFolder.Name = "PetsFolder"
- local Pets = Instance.new("Folder",PetsFolder); Pets.Name = "Pets"
- local PetsValues = Instance.new("Folder",PetsFolder); PetsValues.Name = "Values"
- local PetNameCheck = Instance.new("StringValue",PetsFolder); PetNameCheck.Name = "PetNameCheck"
- --Pets Values
- local Turtle = Instance.new("BoolValue",PetsValues); Turtle.Name = "Turtle"
- local Bunny = Instance.new("BoolValue",PetsValues); Bunny.Name = "Bunny"
- local Parrot = Instance.new("BoolValue",PetsValues); Parrot.Name = "Parrot"
- local PiggyBank = Instance.new("BoolValue",PetsValues); PiggyBank.Name = "Piggy Bank"
- local MrCrab = Instance.new("BoolValue",PetsValues); MrCrab.Name = "Mr.Crab"
- local PufferFish = Instance.new("BoolValue",PetsValues); PufferFish.Name = "Puffer Fish"
- local Hedgehog = Instance.new("BoolValue",PetsValues); Hedgehog.Name = "Hedgehog"
- local CrocodilePal = Instance.new("BoolValue",PetsValues); CrocodilePal.Name = "CrocodilePal"
- local KingFrog = Instance.new("BoolValue",PetsValues); KingFrog.Name = "King Frog"
- local Kitty = Instance.new("BoolValue",PetsValues); Kitty.Name = "Kitty"
- local EpicDuck = Instance.new("BoolValue",PetsValues); EpicDuck.Name = "Epic Duck"
- local Octopus = Instance.new("BoolValue",PetsValues); Octopus.Name = "Octopus"
- local PetRock = Instance.new("BoolValue",PetsValues); PetRock.Name = "Pet Rock"
- local SeaMonster = Instance.new("BoolValue",PetsValues); SeaMonster.Name = "Sea Monster"
- local Pikachu = Instance.new("BoolValue",PetsValues); Pikachu.Name = "Pikachu"
- local OOFSpider = Instance.new("BoolValue",PetsValues); OOFSpider.Name = "OOF Spider"
- local PetGojira = Instance.new("BoolValue",PetsValues); PetGojira.Name = "Pet Gojira"
- local Scorpion = Instance.new("BoolValue",PetsValues); Scorpion.Name = "Scorpion"
- local HungryShark = Instance.new("BoolValue",PetsValues); HungryShark.Name = "Hungry Shark"
- local AnnoyingOrange = Instance.new("BoolValue",PetsValues); AnnoyingOrange.Name = "Annoying Orange"
- local EvilUnicorn = Instance.new("BoolValue",PetsValues); EvilUnicorn.Name = "Evil Unicorn"
- local ArcticReindeer = Instance.new("BoolValue",PetsValues); ArcticReindeer.Name = "Arctic Reindeer"
- local Bird = Instance.new("BoolValue",PetsValues); Bird.Name = "Bird"
- local GrayWolf = Instance.new("BoolValue",PetsValues); GrayWolf.Name = "Gray Wolf"
- local Dog = Instance.new("BoolValue",PetsValues); Dog.Name = "Dog"
- local Otter = Instance.new("BoolValue",PetsValues); Otter.Name = "Otter"
- local AlienBee = Instance.new("BoolValue",PetsValues); AlienBee.Name = "Alien Bee"
- local TRex = Instance.new("BoolValue",PetsValues); TRex.Name = "T-Rex"
- local Phoenix = Instance.new("BoolValue",PetsValues); Phoenix.Name = "Phoenix"
- local HellDragon = Instance.new("BoolValue",PetsValues); HellDragon.Name = "Hell Dragon"
- --Hidden Pet Value
- local HiddenPetValue = Instance.new("BoolValue",PetsValues); HiddenPetValue.Name = "Eye of Cthulhu"
- local Player = "Player_"..player.UserId
- --Load Data
- local data
- local success, errormessage = pcall(function()
- data = Petsdata:GetAsync(Player) --.UserId
- end)
- if success then
- if data then
- PetNameCheck.Value = data.PetNameCheck;
- Turtle.Value = data.Turtle;
- Bunny.Value = data.Bunny;
- Parrot.Value = data.Parrot;
- PiggyBank.Value = data.PiggyBank;
- MrCrab.Value = data.MrCrab;
- PufferFish.Value = data.PufferFish;
- Hedgehog.Value = data.Hedgehog;
- CrocodilePal.Value = data.CrocodilePal;
- KingFrog.Value = data.KingFrog;
- Kitty.Value = data.Kitty;
- EpicDuck.Value = data.EpicDuck;
- Octopus.Value = data.Octopus;
- PetRock.Value = data.PetRock;
- SeaMonster.Value = data.SeaMonster;
- Pikachu.Value = data.Pikachu;
- OOFSpider.Value = data.OOFSpider;
- PetGojira.Value = data.PetGojira;
- Scorpion.Value = data.Scorpion;
- HungryShark.Value = data.HungryShark;
- AnnoyingOrange.Value = data.AnnoyingOrange;
- EvilUnicorn.Value = data.EvilUnicorn;
- ArcticReindeer.Value = data.ArcticReindeer;
- Bird.Value = data.Bird;
- GrayWolf.Value = data.GrayWolf;
- Dog.Value = data.Dog;
- Otter.Value = data.Otter;
- AlienBee.Value = data.AlienBee;
- TRex.Value = data.TRex;
- Phoenix.Value = data.Phoenix;
- HellDragon.Value = data.HellDragon;
- HiddenPetValue.Value = data.HiddenPetValue;
- end
- end
- if player.Character then
- local Pets = game:GetService("ReplicatedStorage").Pets.ActualPets:GetChildren()
- for i,pets in pairs(Pets) do
- if pets:IsA("Model") then
- if player.PetsFolder:FindFirstChild("PetNameCheck").Value == pets.Name then
- local pet = pets:Clone()
- pet.Parent = player.Character
- break
- end
- end
- end
- end
- player.CharacterAdded:Connect(function(Character)
- -- print("Spawn")
- if Character then
- local Pets = game:GetService("ReplicatedStorage").Pets.ActualPets:GetChildren()
- for i,pets in pairs(Pets) do
- if pets:IsA("Model") then
- if player.PetsFolder:FindFirstChild("PetNameCheck").Value == pets.Name then
- local pet = pets:Clone()
- pet.Parent = player.Character
- break
- end
- end
- end
- end
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local Player = "Player_"..player.UserId
- local data = {
- Turtle = player.PetsFolder.Values.Turtle.Value;
- Bunny = player.PetsFolder.Values.Bunny.Value;
- Parrot = player.PetsFolder.Values.Parrot.Value;
- PiggyBank = player.PetsFolder.Values["Piggy Bank"].Value;
- MrCrab = player.PetsFolder.Values["Mr.Crab"].Value;
- PufferFish = player.PetsFolder.Values["Puffer Fish"].Value;
- Hedgehog = player.PetsFolder.Values.Hedgehog.Value;
- CrocodilePal = player.PetsFolder.Values.CrocodilePal.Value;
- KingFrog = player.PetsFolder.Values["King Frog"].Value;
- Kitty = player.PetsFolder.Values.Kitty.Value;
- EpicDuck = player.PetsFolder.Values["Epic Duck"].Value;
- Octopus = player.PetsFolder.Values.Octopus.Value;
- PetRock = player.PetsFolder.Values["Pet Rock"].Value;
- SeaMonster = player.PetsFolder.Values["Sea Monster"].Value;
- Pikachu = player.PetsFolder.Values.Pikachu.Value;
- OOFSpider = player.PetsFolder.Values["OOF Spider"].Value;
- PetGojira = player.PetsFolder.Values["Pet Gojira"].Value;
- Scorpion = player.PetsFolder.Values.Scorpion.Value;
- HungryShark = player.PetsFolder.Values["Hungry Shark"].Value;
- AnnoyingOrange = player.PetsFolder.Values["Annoying Orange"].Value;
- EvilUnicorn = player.PetsFolder.Values["Evil Unicorn"].Value;
- ArcticReindeer = player.PetsFolder.Values["Arctic Reindeer"].Value;
- Bird = player.PetsFolder.Values.Bird.Value;
- GrayWolf = player.PetsFolder.Values["Gray Wolf"].Value;
- Dog = player.PetsFolder.Values.Dog.Value;
- Otter = player.PetsFolder.Values.Otter.Value;
- AlienBee = player.PetsFolder.Values["Alien Bee"].Value;
- TRex = player.PetsFolder.Values["T-Rex"].Value;
- Phoenix = player.PetsFolder.Values.Phoenix.Value;
- HellDragon = player.PetsFolder.Values["Hell Dragon"].Value;
- HiddenPetValue = player.PetsFolder.Values["Eye of Cthulhu"].Value;
- PetNameCheck = player.PetsFolder.PetNameCheck.Value;
- };
- local success, errormessage = pcall(function()
- Petsdata:SetAsync(Player, data)
- end)
- if success then
- print("Pets successfully saved:)")
- else
- print("There was an error!")
- warn(errormessage)
- end
- end)
- PetsPurchaseEvent.OnServerEvent:Connect(function(player,p,PetPrice)
- local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
- -- print("Received Server message")
- -- print(p)
- -- print(p.Name)
- local Values = player.PetsFolder.Values
- for i,v in pairs(Values:GetDescendants()) do
- if v:IsA("BoolValue") then
- --print(v.Name)
- --print(v.Name == p.Name)
- if v.Name == p.Name then
- -- print("To the Next Step")
- -- print(v.Name == p)
- -- print(v.Name)
- -- print(v.Value)
- if v.Value == true then
- -- print(v.Name.." Owned")
- for i,pets in pairs(Pets) do
- -- print(pets.Name)
- if pets:IsA("Model") and p.Name == pets.Name then
- -- print(pets.Name)
- ---- print(v.Name.." v.Name")
- -- print(p.Name.." p.Name")
- -- print(pets.Name.." pets.Name")
- --local previouspet = pets
- local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
- if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= p.Name then --or player.PetsTestFolder:FindFirstChild("PetNameCheck").Value ~= ""
- -- print("Pet owned and its not the same so we will destroy it")
- -- print("Destroy")
- --local pet = player.Character:FindFirstChild(pets.Name):Destroy()
- --player.Character:FindFirstChild(pets.Name):Destroy()
- previouspet:Destroy()
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- break
- end
- if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value == p.Name and v.Name == p.Name then -- also need to fix or player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= p.Name
- -- print("Pet owned and its in inventory so we will destroy it")
- -- print("Destroy")
- --local pet = player.Character:FindFirstChild(pets.Name):Destroy()
- --player.Character:FindFirstChild(pets.Name):Destroy()
- previouspet:Destroy()
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
- break
- end
- if not previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" and v.Name == p.Name and pets.Name == p.Name then -- something is fishy about this line of code
- -- print("Pet owned and its not in inventory so we will clone it")
- -- print("Clone")
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- break
- end
- --[[ if previouspet and v.Name ~= p.Name and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= p.Name then -- something is fishy about this line of code
- previouspet:Destroy()
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- break
- end--]]
- end
- end
- else
- -- print(v.Name.." Not Owned")
- -- print(PetPrice)
- if player.leaderstats.Coins.Value >= PetPrice then
- player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - PetPrice
- v.Value = true
- for i,pets in pairs(Pets) do
- if p.Name == pets.Name then
- local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
- if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then
- -- print("Checking Before Cloning")
- previouspet:Destroy()
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- else
- -- print("Cloning")
- --print(pets)
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- end
- end
- end
- else
- print("Player Doesnt Have the Coin,Hes Poor")
- end
- end
- end
- end
- end
- end)
- PetsGamepassEvent.OnServerEvent:Connect(function(player,id,Name)
- local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
- local success, errormessage = pcall(ownsGamepass);
- --print(player)
- -- print(id)
- -- print(Name)
- if player and not ownsGamepass then
- game:GetService("MarketplaceService"):PromptGamePassPurchase(player,id)
- -- print(Name)
- local function gamepassPurchaseFinished(player,id,wasPurchased)
- Market:Disconnect()
- if wasPurchased == true then
- print("Purchased")
- -- print(id)
- -- print(Name)
- for i,pets in pairs(Pets) do
- --print(pets.Name)
- -- print(Name)
- if pets:IsA("Model") and pets.Name == Name then
- local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
- if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= "" then
- previouspet:Destroy()
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- PetsGamepassEvent:FireClient(player,Name,id)
- else
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- PetsGamepassEvent:FireClient(player,Name,id)
- end
- end
- end
- else
- print("Canceled")
- return
- end
- end
- Market = MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
- end
- if player and ownsGamepass then
- for i,pets in pairs(Pets) do
- --print(pets.Name)
- -- print(Name)
- if pets:IsA("Model") and pets.Name == Name then
- -- print("We own it") -- If we Own the gamepass
- local previouspet = player.Character:FindFirstChild("Turtle") or player.Character:FindFirstChild("Bunny") or player.Character:FindFirstChild("Parrot") or player.Character:FindFirstChild("Piggy Bank") or player.Character:FindFirstChild("Mr.Crab") or player.Character:FindFirstChild("Puffer Fish") or player.Character:FindFirstChild("Hedgehog") or player.Character:FindFirstChild("CrocodilePal") or player.Character:FindFirstChild("King Frog") or player.Character:FindFirstChild("Kitty") or player.Character:FindFirstChild("Epic Duck") or player.Character:FindFirstChild("Octopus") or player.Character:FindFirstChild("Pet Rock") or player.Character:FindFirstChild("Sea Monster") or player.Character:FindFirstChild("Pikachu") or player.Character:FindFirstChild("OOF Spider") or player.Character:FindFirstChild("Pet Gojira") or player.Character:FindFirstChild("Scorpion") or player.Character:FindFirstChild("Hungry Shark") or player.Character:FindFirstChild("Annoying Orange") or player.Character:FindFirstChild("Evil Unicorn") or player.Character:FindFirstChild("Arctic Reindeer") or player.Character:FindFirstChild("Bird") or player.Character:FindFirstChild("Gray Wolf") or player.Character:FindFirstChild("Dog") or player.Character:FindFirstChild("Otter") or player.Character:FindFirstChild("Alien Bee") or player.Character:FindFirstChild("T-Rex") or player.Character:FindFirstChild("Phoenix") or player.Character:FindFirstChild("Hell Dragon") or player.Character:FindFirstChild("Dragon") or player.Character:FindFirstChild("DragonTest") or player.Character:FindFirstChild("Shadow Dragon") or player.Character:FindFirstChild("Megavore") or player.Character:FindFirstChild("Magma Dragon") or player.Character:FindFirstChild("Eye of Cthulhu")
- if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value ~= Name then
- print("idk")
- previouspet:Destroy()
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- PetsGamepassEvent:FireClient(player,Name,id)
- break
- end
- if previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value == Name and previouspet.Name == Name then
- print("idk")
- previouspet:Destroy()
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = ""
- PetsGamepassEvent:FireClient(player,Name,id)
- break
- end
- if not previouspet and player.PetsFolder:FindFirstChild("PetNameCheck").Value == "" and pets.Name == Name then
- print("idk")
- local pet = pets:Clone()
- pet.Parent = player.Character
- player.PetsFolder:FindFirstChild("PetNameCheck").Value = pets.Name
- PetsGamepassEvent:FireClient(player,Name,id)
- break
- end
- end
- end
- end
- end)
Add Comment
Please, Sign In to add comment