SmartValueService (NO LONGER PUBLIC, DM FOR SOURCE) | Get what ValueBase fits your needs based on your value!

Read this

SmartValueService

Are you tired of checking values and making a valuebase according to the value?
Worry no more, because SmartValueService fixes this!

It is a simple module yet useful for developers who are tired of Roblox not having a global valuebase that stores everything like attributes

How to install:

How to use:

Once you have the module script, place it inside wherever you want, take into account that if you’re going to use it from the client you can’t require it from services that aren’t replicated to the client (such as serverstorage)

Now you should make a script and paste this code:

local PathToModule = game:GetService("ServerScriptService") --This is the path to the module
local SmartValueBaseModule = require(pathToModule.SmartValueService)
--Examples:

local classname1 = SmartValueBaseModule:GetClassName("Yummy")
--This will return "StringValue"

local classname2 = SmartValueBaseModule:GetClassName(true)
--This will return "BoolValue"

Usage:

This module is useful to use with Instance.new() according to the value

local PathToModule = game:GetService("ServerScriptService") --This is the path to the module
local SmartValueBaseModule = require(pathToModule.SmartValueService)

local classname1 = SmartValueBaseModule:GetClassName("Yummy")
Instance.new(classname1) --It will make a stringValue

Important notice:

Although this module will never error, your code can do so. If you use values that aren’t supported by valuebases, it will return nil. Look at this code to see how to fix it if you are a beginner.

--This script will error
local PathToModule = game:GetService("ServerScriptService") --This is the path to the module
local SmartValueBaseModule = require(pathToModule.SmartValueService)

local classname1 = SmartValueBaseModule:ReturnClassNameAccordingToValue({})
--classname1 is nil because tables aren't supported inside valuebases!
--Therefore:
Instance.new(classname1) --Will error because of nil
--This script won't error
local PathToModule = game:GetService("ServerScriptService") --This is the path to the module
local SmartValueBaseModule = require(pathToModule.SmartValueService)

local classname1 = SmartValueBaseModule:GetClassName{})
--classname1 is nil
--Therefore:
if classname1 then --Will check if classname1 exists (you can also use ~= nil)
      Instance.new(classname1) --Will error because of nil
else
      --Code to run if it is not supported
end

Reason to use this module?

This module uses a dictionary that has stored each valuebase classname indexed by its typeof (“Instance”, “boolean”, etc…). Indexing dictionaries is much faster than using arrays with for loops or spamming else ifs because it retrieves the indexed value instead of searching for every value in the array.

Info:

The documentation is inside the modulescript

This module may be easy to create, but I wanted to make it to help some beginners, or even code what some may be lazy to do and just use stringvalues for everything (totally not me in the past) hehe! I hope you like it.

2 Likes

Could you perhaps decrease the length of this function name to something more practical, such as “GetClassName”?

1 Like

You can edit the module functions if you wish! I’ll just leave it as it was because it may interfere with my already written scripts! :slight_smile:

No offense. but you can already do this:

local typ = typeof("str") == "string"
if typ then
   print("good value")
else
   print("bad value")
end

Have you read the module mate? This module gives you a valuebase classname according to a value

String → StringValue

Boolean → BoolValue

Number → NumberValue or IntValue (if the number is an integer and you set TransformNumberToInt to true)

Etc

1 Like

ohh im an idiot. sorry. i might use this

2 Likes

UPDATE

CHANGES:

->Changed the name of the module

->Changed the name of some functions

->Added documentation inside the modulescript

->Optimization improvements

THIS MODULE IS NO LONGER PUBLIC, AS IT DIDN’T MEET MY EXPECTATIONS

If you are interested in viewing the source code, DM me.