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

How do you save parts BrickColor?

Asked by 4 years ago
Edited 4 years ago

so i tried to make a simple script that literally just saves a brick color. heres the not working script:

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("DS1")
game.Players.PlayerAdded:Connect(function(plr)
    local part= game.Workspace.Part
    local success,err = pcall(function()
        part.BrickColor = ds1:GetAsync(plr.UserId)
    end)
    if success then
        print("Your Data Has Been Loaded.")
    else
        print("Your Data Loading Has Failed.")
        warn(err)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local part= game.Workspace.Part
    local success,err = pcall(function()
        ds1:SetAsync(plr.UserId, part.BrickColor)
    end)
    if success then
        print("Your Data Has Been Saved.")
    else
        print("We Got An Error While Saving Your Data.")
        warn(err)
    end
end)

i would appreciate any help.

0
Better use color3. Cuz that really easier IiTossiI -2 — 4y
0
Have you tried storing the BrickColor as a string, and then reconstructing the BrickColor from the string? I think this documentation (https://developer.roblox.com/en-us/api-reference/datatype/BrickColor) can help you store the color as a string, then reconstruct it as a BrickColor when you need to do so. y3_th 176 — 4y
0
Yeah ^^ you can royaltoe 5144 — 4y
0
only save numbers, strings or tables to datastore royaltoe 5144 — 4y

Answer this question