Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to convert a string into a userdata value?

Asked by 7 years ago
Edited 7 years ago

Hey guys, I've been working on transitioning 1 color to another smoothly when it's going through all of it's phases and I have run across an issue where I need the string that I stored in the dictionary to convert back into a userdata value. It's easy to convert a userdata value to a string however, I am not sure how to do the opposite of that.

Color module script that contains the whole dictionary and returns a BrickColor in it's color3 value as a string can be found here.

Transitioning module script can be found here.

Local script that calls both modules can be found here.

The local script will print 'nil' if I ask it to print color1.Color.r because it's not a userdata value, it's a String. I was wondering how I can covert color1 and color2 to userdata values so I can perform arithmetic on them and, I've tried to do tonumber() on it but, it forms an entirely different number that will not help me with my transition.

Thank you for any help and I know it might look like I am asking to solve a huge problem because of 3 different scripts and 2 of them being module scripts but, it's not really that big of an issue, just want to know how I might go about converting a String to a UserData Value.

~~ KingLoneCat

0
You could convert your strings in the Color Module to tables(Ex: ["Cadet blue"] = {0.6235294342041,0.678431391716,0.75294125080109}) and then use it from there. You could also use string patterns so you wouldn't have to go through each table, but I'm not very good at those, antonio6643 426 — 7y
0
Thanks, you're a genius. KingLoneCat 2642 — 7y

Answer this question