Script isn't working or printing

That’s right too. But if it’s a typo in the module why doesn’t it give an error or warning.

It’s not a syntax error; I just think it was put in the wrong place due to the fact it works for me but not for him.

Also, question. In the script, did line 1 print correctly?

That was this line:

print("im quirky for writing this way")
1 Like

no, NOTHING APPEARS IN OUTPUT WHATSOEVRER I DONT KNOW WHYU

Are you using a LocalScript for detecting click

yes, but how does this make any difference, it works for @xRo_Fishy

Oh wait. That’s it. I’m using a script, not a local script.

1 Like

Where is the script located?

use a normal script it must work

The part should also be inside of Workspace. Use a normal script and place it inside the part, and make sure the part also has a clickdetector inside of it. Also, place the moduleScript inside of ServerScriptService

you guys are damn geniuses, ok but now I get this in output:

 ReplicatedStorage.Basic:57: attempt to index nil with 'Common'

and it goes to "local raritytable = BasicEgg.Block[rarity]

Change BasicEgg.Block to BasicEgg.Blocks

What do you change on the script :joy: :rofl: :sob:

now I get this in output:

 ReplicatedStorage.Basic:58: invalid argument #2 to 'random' (interval is empty)

Can I see your script and module script right now? Also change BasicEgg.Blocks back to BasicEgg.Block I was wrong lol.

1 Like

script:

print("im quirky for writing this way")
local cost = 500
local blockModule = require(game:GetService("ReplicatedStorage"):WaitForChild("Basic"))

local clickieClick = script.Parent:WaitForChild("ClickDetector")

clickieClick.MouseClick: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)

module:

local BasicEgg = {}


BasicEgg.Blocks = {

	["Godly"] = {
		
	};

	["Legendary"] = {

	};

	["Epic"] = {

	};

	["Rare"] = {

	};

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

	["Common"] = {
	
	};
}

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

Also, are you requiring this module script in any other scripts in your game besides the one that you shared in your original post?

1 Like

noooooooooooooooooooooooooooooooooooooooooooo no it isn’t

Got the issue.

In line 27, paste this:

game:GetService("ReplicatedStorage"):WaitForChild("Items"):WaitForChild("Blocks"):WaitForChild("")

Then, create a part inside of the ‘Blocks’ folder

image

And give it no name (delete the name and press enter)

Why haven’t you change BasicEgg.Blocks to BasicEgg.Block?

1 Like