I Need Help At My Script!

  1. What do you want to achieve?

I want to see (pet…name) in the output and to take 800 Coins from the leaderboard.

  1. What is the issue? Forum Help

script:

local petModule = {}

petModule.pets = {

["Mythic"] = {
	
};

["Legendary"] = {
	
};

["Epic"] = {
	
};

["UnCommon"] = {
	game.ReplicatedStorage.Pets.BlackCaterpillar;
	game.ReplicatedStorage.Pets.WhiteCaterpillar;
};

["Common"] = {
	game.ReplicatedStorage.Pets.GreenCaterpillar;
	game.ReplicatedStorage.Pets.DarkGreenCaterpillar;
	game.ReplicatedStorage.Pets.LightGreenCaterpillar;
};

}

petModule.rarities = {

["Mythic"] = 1;

["Legendary"] = 3;

["Epic"] = 17;

["UnCommon"] = 24;

["Common"] = 55;

}

petModule.chooseRandomPet = function()

local randomNumber = math.random(1,100)

local counter = 0

for rarity, weight in pairs(petModule.rarities) do
	counter = counter + weight
	if randomNumber <= counter then
		
		local rarityTable = petModule.pet[rarity]
		local chosePet = rarityTable[math.random(1,#rarityTable)]
		
		return chosePet
		
	end
end

end

return module

  1. What solutions have you tried so far?
    I tried to change it into the Replicated Stoarge.

Can you show your script/error as well as PetModule

This means that your calling WaitForChild on the PetModule inside of a script parented to EggCapsule.Part and it does not exist. Furthermore, you rarely need to use WFC from the server.

1 Like

Hello, this question will be closed (not by me) if you do not show us your code. It would be really helpful, if you could give us your code so that we can analyze and pin point your errors.