Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local BuyPet = ReplicatedStorage:WaitForChild("BuyPet")
- BuyPet.OnServerEvent:Connect(function(Player, PetName)
- local Pet = ReplicatedStorage.petsFolder:FindFirstChild(PetName)
- if not Pet then
- return
- end
- local OwnedPets = Player:FindFirstChild("OwnedPets")
- if not OwnedPets then
- OwnedPets = Instance.new("Folder")
- OwnedPets.Name = "OwnedPets"
- OwnedPets.Parent = Player
- end
- -- Ya la tiene comprada
- if OwnedPets:FindFirstChild(PetName) then
- return
- end
- local Coins = Player:FindFirstChild("Coins")
- if not Coins then return end
- local Price = Pet.Price.Value
- if Coins.Value >= Price then
- Coins.Value -= Price
- local Value = Instance.new("BoolValue")
- Value.Name = PetName
- Value.Parent = OwnedPets
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment