Hello, I am pretty new to roblox scripting like truly trying to learn it. I have been trying to make a rarity system as I had used a module script. I had set the module script up like such:
local rarityChance = {}
function Rarity = {
Uncommon = 50,
Common = 25,
Rare = 15,
Ultra = 5,
God = 1,
}
return rarityChance
I know there is something wrong when I try to call my Module Script.
The concept was you walk to your block click it with the Click Detector function and then your script is inside. Once clicked it would choose a random rarity but i’m stuck at showing the table and not being able to get it as a percentage.
I recommend learning the basics of scripting before trying to ask questions within the forum, there’s a variety of resources to use that will help greatly with your future endeavors into scripting. (provided below)
If you take these into consideration then good luck!! It’s always nice to see more scripters
I know the basics of scripting in roblox. I have made games and such just nothing super crazy front page stuff. Just stuck on certain ways to go about the code I guess is the best way to describe it. I have made my code work I just take like 9 years, so I thought id ask for some extra help. Thanks for the reply!
The script he posted means practically nothing? I don’t understand the point of your reply to mine, it’s clear that he lacks understanding of modules or anything related to tables, when he returns “rarityChance” he for some reasons adds {} at the end of it for no apparent reason, “function Rarity = {” doesn’t mean anything and doesn’t work at all, showing lack of understanding of what functions are. I didn’t mean any harm from what I said and was merely giving him resources where to learn the information he’s trying to achieve.
No. If you actually read it, you could see that he is actually trying to help the reader. He is showing how he’d see the system working, calling a function with the table of rarities. Please, for the love of god, stop just being an absolute jerk and actually help these people asking questions. This is a forum… in the category that is SPECIFICALLY MADE for getting help. You should be welcoming, but instead you’re just being useless, making spam replies.
I was not being a jerk in any regard? The function he tried making clearly didn’t work even on the most basic level, one of the most necessary requirements of roblox scripting, is it not beyond me to assume he lacks understanding of functions, which would also lead me to believe he hasn’t done much practicing within the subject. I apologize that you believe I came off in a harsh way but I promise I did not mean to come off in such a way.
He never actually defined the function in his post, so I don’t know what you are talking about. In your fashion…
I recommend learning the basics of the DevForum before trying to answer questions within the forum, there’s a variety of resources to use that will help greatly with your future endeavours into helping people. (provided below)
If you take these into consideration then good luck!! It’s always nice to see more forum members
I did thank you! I really appreciate you putting links for me to view and read more to expand my knowledge and to hopefully really help people one day!
I’m unsure if you’re joking, but I won’t continue this after my post, you may report me if you’d like, aggression towards me is childish though (mostly due to the fact I’ve done nothing wrong and are completely in the right). Beyond this minor “scuffle”, have a nice day.
You can think what you need to off of a post that had a few lines of code, I’m sorry you feel threatened to have to say to someone asking for help that they don’t understand. Which you really do not know me so how would one be able to assume? Just off a simple mistake. Its the same as a spelling mistake.
Seems like your module its not correctly closed at the end, maybe thats the issue why not being able to print it when player clicked.
Probably this is not the best way to achieve the goal, but I would do this to not complicate too much, kinda hardcoded but it works:
The module that holds the rarity table, and perform the check how rare is a number given, will return the name of the rarity:
local rarityChance = {}
rarityChance.RarenessTable = {
Common = {1,49}, -- 50
UnCommon = {50,74}, -- 25
Rare = {75,89}, -- 15
Ultra = {90,98}, -- 9
God = {99,100} -- 1
}
rarityChance.DoRarity = function(number)
for rarity, rares in pairs(rarityChance.RarenessTable) do
if number >= rares[1] and number <= rares[2] then
return rarity
end
end
end
return rarityChance
A server script inside a part with a click detector that will create a random number from 0,100, to ask module what is the rarity of that number:
local rarityChance = require(game:GetService("ServerScriptService"):WaitForChild("rarityChance"))
local PartToClick = game.Workspace.PartToClick
PartToClick.ClickDetector.MouseClick:Connect(function()
local randNumb = math.random(1,100)
local doRarity = rarityChance.DoRarity(randNumb)
warn(randNumb, "it's:", doRarity)
end)