Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- all this is inside one local script used for over 33 Frames:O
- local RS = game:GetService("ReplicatedStorage") -- the actual Service in what we have all the Pets,Events stored and etc.
- local PetsFolder = RS.Pets
- local PetsFrameEvent = PetsFolder.PetEvents.PetFrame -- the event that we need for the purchase frame to pop up
- 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
- for i,v in pairs(MainFrame:GetDescendants())do
- if v:IsA("ImageButton") and v.Name == "PetsButton" then -- checks if theres a image button and its name is equal to "PetsButton"
- v.MouseButton1Down:Connect(function() -- this function will fire if the requirments above are true!!
- if debounce and player then -- check if debounce is true theres a player , this is optimal tho,not nessesary
- if player.leaderstats.Coins.Value >= v.Price.Value then -- checks if the player has Coins
- debounce = false
- -- print("hi my nigga") -- prints once
- --wait(.1)
- PetsFrameEvent:FireServer() -- Fires from client to server to check if the player owns the pet or not:P(Fires once)
- debounce = true
- else -- if player doesnt have enough Coins then the RemoteEvent above wont execute and this will!!
- v.PetPriceCheck.Text = "Not Enough Coins"
- wait(1)
- v.PetPriceCheck.Text = v.Price.Value .. " Coins" -- resets the price to its default per pet
- end
- end
- end)
- end
- if v:IsA("ImageButton") and v.Name == "PetsGamepassButton" then -- gamepass 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
- print("not my nigga")
- end
- end)
- end
- if v:IsA("ImageButton") and v.Name == "PetsHiddenButton" then -- gamepass 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
- PetsFrameEvent.OnClientEvent:Connect(function(Index) -- when the remote event on the server fires 15 times for no reason it receives the info in here once and i wanted it once:P,but thats a small but i need to figure out in future!!
- if debounce then
- local Player = game:GetService("Players").LocalPlayer
- for i,v in pairs(MainFrame:GetDescendants())do
- --v:GetChildren()
- --print(v)
- if v:IsA("ImageButton") and v.Name == "PetsButton" then
- v.Activated:Connect(function(Index)
- debounce = false
- print(v)
- 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(PetName)
- wait()
- 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
- end)
- end
- end
- wait(2)
- debounce = true
- end
- end)
- --From Below this line is the stuff inside the serve script same checks for idk it shoudnt even matter cause its locally but yeah!!
- PetsFrameEvent.OnServerEvent:Connect(function(player)
- local MainFrame = player.PlayerGui.MusicGui.ShopFrame.ShopFrame2.ScrollingFrame
- for i,v in pairs(MainFrame:GetDescendants()) do
- if v:IsA("ImageButton") and v.Name == "PetsButton" and debounce and player then
- if player.leaderstats.Coins.Value >= v:FindFirstChild("Price").Value then
- debounce = false
- PetsFrameEvent:FireClient(player)-- for some stupid reason it fires 15 times tho its super fast but on client he get the info once so its a good thing i guess!!
- -- print("not nigga")
- --wait(.1)
- debounce = true
- end
- end
- end
- end)
- -- In the end i saw Bermuda Triangle client,server,client:D
Add Comment
Please, Sign In to add comment