local cost = 50
local petModule = require(game:GetService("ServerScriptService"):WaitForChild("PetModule")) script.Parent.ClickDetector.MouseClick:Connect(function(player) if player.leaderstats.Cash.Value >= cost then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - cost
local pet = petModule.chooseRandomPet()
local petVal = Instance.new("StringValue")
petVal.Name = pet.Name -- here!
petVal.Parent = player.PetInventory
game.ReplicatedStorage.HatchEgg:FireClient(player, pet)
end
end)

3 comments
Does petModule.chooseRandomPet() return an Instance?
petModule.chooseRandomPet() is possibly not returning anything
it is wierd because sometimes it works and sometimes it doesnt