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.
local datastoreservice = game:GetService("DataStoreService"):GetDataStore("BrickColorDatastore")
local part = game.Workspace.coolpart
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
part.BrickColor = BrickColor.new("Really red")
end
end)
game.Players.PlayerAdded:Connect(function(player)
local success,errmsg = pcall(function()
datastoreservice:SetAsync(player.UserId,part.BrickColor)
part.BrickColor = BrickColor.new("Really red")
end)
if success then
print("Part's color has been stored")
else
print("Part's color failed to store")
warn(errmsg)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errmsg = pcall(function()
datastoreservice:SetAsync(player.UserId,part.BrickColor)
end)
if success then
print("Data store successed")
else
print("Data store failed")
warn(errmsg)
end
end)
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..?

2 comments
I think maybe you should be GETTING the Async when you join not setting it but that's just me
I tried that but sorry it didn't work but thanks for trying to help