print("im quirky for writing this way")
local cost = 500
local blockModule = require(game:GetService("ServerScriptService"):WaitForChild("Basic"))
local clickieClick = script.Parent:WaitForChild("ClickDetector")
clickieClick.MouseHoverEnter:Connect(function(player)
print("I have lost all my sanity")
if player.leaderstats["Bloxy Cash"].Value >= cost then
player.leaderstats["Bloxy Cash"].Value = player.leaderstats["Bloxy Cash"].Value - cost
print("AAAAAAAAAAAAAAAAAAAAAAAAAAA")
local block = blockModule.ChooseRandomBlock()
print(block.Name)
end
end)
I’m making a pet system, except it’s for blocks.
I made a module script, which I will show you.
This script is for the egg I’m currently working on:
local BasicEgg = {}
BasicEgg.Blocks = {
["Godly"] = {
};
["Legendary"] = {
};
["Epic"] = {
};
["Rare"] = {
};
["Uncommon"] = {
game:GetService("ReplicatedStorage"):WaitForChild("Items"):WaitForChild("Blocks"):WaitForChild("PurpleBlock")
};
["Common"] = {
game:GetService("ReplicatedStorage"):WaitForChild("Items"):WaitForChild("Blocks"):WaitForChild("")
};
}
BasicEgg.Rarities = {
["Godly"] = 0.25;
["Legendary"] = 2.75;
["Epic"] = 5;
["Rare"] = 15;
["Uncommon"] = 25;
["Common"] = 52;
}
BasicEgg.ChooseRandomBlock = function()
local random = math.random(1,100)
local counter = 0
for rarity, weight in pairs(BasicEgg.Rarities) do
counter = counter + weight
if random <= counter then
local raritytable = BasicEgg.Block(rarity)
local chosenblock = raritytable[math.random(1, #raritytable)]
return chosenblock
end
end
end
return BasicEgg
I would also like to note that I have another Module script that’s very similar to “Basic”:
-- Note: not all of this script is mine! I have researched and saw other peoples' scripts, and basing my script off of their's
local blockModuleReleaseEgg = {}
blockModuleReleaseEgg.Blocks = {
["Godly"] = {
game:GetService("ReplicatedStorage"):WaitForChild("Items"):WaitForChild("Blocks"):WaitForChild("Rainbow_Block")
};
["Legendary"] = {
game:GetService("ReplicatedStorage"):WaitForChild("Items"):WaitForChild("Blocks"):WaitForChild("Neon_RedBlock")
};
["Epic"] = {
};
["Rare"] = {
};
["Uncommon"] = {
};
["Common"] = {
};
}
blockModuleReleaseEgg.Rarities = {
["Godly"] = 0.25;
["Legendary"] = 2.75;
["Epic"] = 5;
["Rare"] = 15;
["Uncommon"] = 25;
["Common"] = 52;
}
blockModuleReleaseEgg.ChooseRandomBlock = function()
local random = math.random(1,100)
local counter = 0
for rarity, weight in pairs(blockModuleReleaseEgg.Rarities) do
counter = counter + weight
if random <= counter then
local raritytable = blockModuleReleaseEgg.Block(rarity)
local chosenblock = raritytable[math.random(1, #raritytable)]
return chosenblock
end
end
end
Hi, I just copied your script and tested it inside of my game, and everything seems to be working.
I am pretty sure the issue on your end is in line 23 & 27 of the Basic Module script, since originally it gave me an error of an infinite yield on those, but once I fixed that, it worked fine.