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.

game.Players.PlayerAdded:Connect(function(plr)
    local col =  plr:WaitForChild("Stats").Color.Value
    local char = plr.CharacterAdded:Wait()
    local colour = tonumber(col)

    char.Head.Color = colour 
    char.Torso.Color = colour 
    char["Left Leg"].Color = colour
    char["Left Arm"].Color =  colour
    char["Right Arm"].Color =  colour
    char["Right Leg"].Color =  colour
end)

That's my current script for that.

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

local DataStore2 = require(1936396537)

game.ReplicatedStorage.Events.ColourEvent1.OnServerEvent:Connect(function(plr, colour)

    local colorDataStore = DataStore2("color", plr)
    local char = plr.Character
    local colour2 = tostring(colour)

    colorDataStore:Set(colour2)

    char.Head.Color = colour
    char.Torso.Color = colour
    char["Left Leg"].Color = colour
    char["Left Arm"].Color = colour
    char["Right Arm"].Color = colour
    char["Right Leg"].Color = colour

end)

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