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

Color3 Wanted, got string. How to convert any string to color3?

Asked by 5 years ago

I'm making a skin colour changer. It has a datastore and it saves the skin color that you choose to the datastore and changes skin color. When you rejoin the game it should spawn as the last skin colour you chose because it saves to datastore, but when I try to change the Character's body parts to that piece of data it says: Color3 wanted, got string.

01game.Players.PlayerAdded:Connect(function(plr)
02    local col =  plr:WaitForChild("Stats").Color.Value
03    local char = plr.CharacterAdded:Wait()
04    local colour = tonumber(col)
05 
06    char.Head.Color = colour
07    char.Torso.Color = colour
08    char["Left Leg"].Color = colour
09    char["Left Arm"].Color =  colour
10    char["Right Arm"].Color =  colour
11    char["Right Leg"].Color =  colour
12end)

That's my current script for that.

This is what saves it to the datastore and this works fine:

01local DataStore2 = require(1936396537)
02 
03game.ReplicatedStorage.Events.ColourEvent1.OnServerEvent:Connect(function(plr, colour)
04 
05    local colorDataStore = DataStore2("color", plr)
06    local char = plr.Character
07    local colour2 = tostring(colour)
08 
09    colorDataStore:Set(colour2)
10 
11    char.Head.Color = colour
12    char.Torso.Color = colour
13    char["Left Leg"].Color = colour
14    char["Left Arm"].Color = colour
15    char["Right Arm"].Color = colour
16    char["Right Leg"].Color = colour
17 
18end)

I have eight different colour types, and when you click it, it will fire event and send the background colour to the script. Then it saves to datastore. When a player leaves and rejoins it should make the skin colour what that datastore value is. (the colour)

1
@Bluesteelkid, you can save the color as a RGB value saving each individually. BlackOrange3343 2676 — 5y
1
@Bluesteelkid or if you want BrickColors, you can save the name as a string BlackOrange3343 2676 — 5y
0
I'm assuming that plr:WaitForChild("Stats").Color.Value is a color3 value? XviperIink 428 — 5y
0
Color3.fromRGB(red,green,blue) may help you i guess (?) RAFA1608 543 — 5y

Answer this question