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

Is it possible to use DataStore to save other things than values?

Asked by 7 years ago
Edited 7 years ago

I have a script that randomizes the Character's appearence when they join, it goes to local storage, randomly picks some stuff I put in folders and such then loads the person character.

The thing is, this script randomizes again on reset/ leave. Which I don't want to do. I've thinking I've gotten pretty familiar with datastores, but I do not know how to go about saving the character appearence if its not a value on a table.

Though, I was also wondering is it possible to copy the character, make it a value, then store it like that? Also this is the randomizing script.

game.Players.PlayerAdded:connect (function(players)
     players.CharacterAdded:connect (function(character)
        delay(1, function()
            local Uniform = character:GetChildren()

            for i = 1, #Uniform do
                if Uniform[i].ClassName=="Accessory" or Uniform[i].ClassName == "ShirtGraphic" or Uniform[i].ClassName=="Pants" or Uniform[i].ClassName == "Shirt" or Uniform[i].ClassName == "BodyColors" or Uniform[i].ClassName == "CharacterMesh" then
                    Uniform[i]:Remove()
                end
            end
            local hat1 = game.ServerStorage.Uniform.Hats1:GetChildren()
            if #hat1 >0 then
            local i = math.random (1,#hat1)
            hat1[i]:Clone().Parent = character
            end

            local hat2 = game.ServerStorage.Uniform.Hats2:GetChildren()
            if #hat2 >0 then
            local i = math.random (1,#hat2)
            hat2[i]:Clone().Parent = character
            end

            local hat3 = game.ServerStorage.Uniform.Hats3:GetChildren()
            if #hat3 >0 then
            local i = math.random (1,#hat3)
            hat3[i]:Clone().Parent= character
            end

            local shirts = game.ServerStorage.Uniform.Shirts:GetChildren()
            if #shirts >0 then
            local i = math.random(1,#shirts)
            shirts[i]:Clone().Parent = character
            end

            local Pants = game.ServerStorage.Uniform.Pants:GetChildren()
            if #Pants >0 then
            local i = math.random (1,#Pants)
            Pants[i]:Clone().Parent=character
            end     

            local bodycolor = game.ServerStorage.Uniform.BodyColors:GetChildren()
            if #bodycolor >0 then
            local i = math.random(1,#bodycolor)

            character:FindFirstChild("LeftFoot").BrickColor = bodycolor[i].Value
            character:FindFirstChild("LeftHand").BrickColor = bodycolor[i].Value
            character:FindFirstChild("LeftUpperArm").BrickColor = bodycolor[i].Value
            character:FindFirstChild("RightUpperArm").BrickColor = bodycolor[i].Value
            character:FindFirstChild("LeftLowerLeg").BrickColor = bodycolor[i].Value
            character:FindFirstChild("LeftLowerArm").BrickColor = bodycolor[i].Value
            character:FindFirstChild("LeftUpperLeg").BrickColor = bodycolor[i].Value
            character:FindFirstChild("LowerTorso").BrickColor = bodycolor[i].Value
            character:FindFirstChild("RightFoot").BrickColor = bodycolor[i].Value
            character:FindFirstChild("RightHand").BrickColor = bodycolor[i].Value
            character:FindFirstChild("RightLowerArm").BrickColor = bodycolor[i].Value
            character:FindFirstChild("RightUpperLeg").BrickColor = bodycolor[i].Value
            character:FindFirstChild("UpperTorso").BrickColor = bodycolor[i].Value
            character:FindFirstChild("Head").BrickColor = bodycolor[i].Value
            end

        local faces = game.ServerStorage.Uniform.Faces:GetChildren()
        if #faces > 0 then
        local stuff2 = character.Head:GetChildren()
        for i =1,#stuff2 do
            if stuff2[i].ClassName=="Decal" then
                stuff2[i]:Remove()
            end
        end

        local i = math.random(1,#faces)
        faces[i]:Clone().Parent = character.Head    
        end

        local packages = game.ServerStorage.Uniform.Package:GetChildren()
        if #packages > 0 then
        local i = math.random (1,#packages)
        local stuff3 = packages[i]:GetChildren()
        for i = 1, #stuff3 do
            stuff3[i]:Clone().Parent = character
                end
            end
        end)
    end)
end)
0
You could possibly give each item a code number and if it's that code numbers it triggers iRexBot 147 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Yes you can store a table using a iterator.

However, it's not possible to save a object, but you can save string values and numbers.

Ad

Answer this question