Data store script to store a part's property isn't working?
I wanna make it so when the part is touched it changes it's color, also I want it to Data Store that part's Color when a player joins and when a player leaves, it's my first time trying to Data Store a part's property so of course it's going to fail the first time and that's why I'm here, to get some help from you Advanced scripters. :D
Code, a bit too long.
01 | local datastoreservice = game:GetService( "DataStoreService" ):GetDataStore( "BrickColorDatastore" ) |
02 | local part = game.Workspace.coolpart |
04 | part.Touched:Connect( function (hit) |
05 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
06 | part.BrickColor = BrickColor.new( "Really red" ) |
11 | game.Players.PlayerAdded:Connect( function (player) |
12 | local success,errmsg = pcall ( function () |
13 | datastoreservice:SetAsync(player.UserId,part.BrickColor) |
14 | part.BrickColor = BrickColor.new( "Really red" ) |
18 | print ( "Part's color has been stored" ) |
20 | print ( "Part's color failed to store" ) |
27 | game.Players.PlayerRemoving:Connect( function (player) |
28 | local success, errmsg = pcall ( function () |
29 | datastoreservice:SetAsync(player.UserId,part.BrickColor) |
32 | print ( "Data store successed" ) |
34 | print ( "Data store failed" ) |
Output errors:
So this is what the output is showing when I join the game in Roblox Studio:
Cannot store int in data store. Data stores can only accept valid UTF-8 characters.
Details.
I don't really know if its possible to data store a part's property but I believe it can.
The script
is parented to ServerScriptService
The Part
name is "coolpart". Probably not helpful of a detail.
Anyways, thanks for helping if you did or tried your best, I think it's a easy thing for you to solve this right..?