Script isn't working or printing

script:

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 have no idea why this isn’t working.

6 Likes

So which part of the script exactly isnt working?

1 Like

sorry, Im sleep deprived, i forgot to tell you that it’s the first script that is completely not working. it deosn’t even print.

I think the problem is that common blocks wait for nothing

["Common"] = {
	game:GetService("ReplicatedStorage"):WaitForChild("Items"):WaitForChild("Blocks"):WaitForChild("")
};
1 Like

Hey! I tried that, still didn’t work. ಥ_ಥ

Where’s the script located? And I recommend moving the modulescript into ReplicatedStorage

1 Like

This module script is in ServerScriptService

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

Is it possible that this is the reason?

I don’t think this module has nothing to do with the ClickDetector script.

Is there an error or warnings? Can you show me?

1 Like

literally nothing is happening in output.

It’s so weird. Are you hovering in distance?

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.

image
Once I added this to ReplicatedStorage it worked.

Hope this helps!

1 Like

I went to a backup 10 days ago, and now I see a lot of print statements in output, i have no idea what is wrong.

Hey, is the answer above solved your problem?

Hey! I tried that, “PurpleBlock” was already there! Sorry, but it didn’t work.

Can you give me a hint where was line 23 & 37 because the code above not really indented correctly (so much spaces)

Line 23 and 27 were here:

Line 23 was the first game:getService(“ReplicatedStorage”) and line 27 was the second one

["Uncommon"] = {
		game:GetService("ReplicatedStorage"):WaitForChild("Items"):WaitForChild("Blocks"):WaitForChild("PurpleBlock")
	};

	["Common"] = {
		game:GetService("ReplicatedStorage"):WaitForChild("Items"):WaitForChild("Blocks"):WaitForChild("")
	};```

Try changing BasicEgg.Block(rarity) to BasicEgg.Blocks[rarity]

I changed the “” line, again still doesn’t work.

Again, I would like to note that NOTHING APPEARS IN OUTPUT!

I just twent back to a backup that was made 13 days ago as a test to see if it works, I can see some print statements.

Where did you put the script? For me, I put it inside of a part in workspace with a click detector and it seemed to work.