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

Data store script to store a part's property isn't working?

Asked by 4 years ago

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.

01local datastoreservice = game:GetService("DataStoreService"):GetDataStore("BrickColorDatastore")
02local part = game.Workspace.coolpart
03 
04part.Touched:Connect(function(hit)
05    if hit.Parent:FindFirstChild("Humanoid") then
06        part.BrickColor = BrickColor.new("Really red")
07    end
08end)
09 
10 
11game.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")
15    end)
View all 37 lines...

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..?

0
I think maybe you should be GETTING the Async when you join not setting it but that's just me AngryPlaayer 17 — 4y
0
I tried that but sorry it didn't work but thanks for trying to help ZombieApocalypz3 35 — 4y

1 answer

Log in to vote
-1
Answered by 4 years ago

I think it means you have to store the value in less than 8 characters. You should find a way to shorten the color value, here's a solution that may not be the GREATEST but, it fixes your problem.

01local datastoreservice = game:GetService("DataStoreService"):GetDataStore("BrickColorDatastore")
02local part = game.Workspace.coolpart
03 
04part.Touched:Connect(function(hit)
05    if hit.Parent:FindFirstChild("Humanoid") then
06        part.BrickColor = BrickColor.new("Really red")
07    end
08end)
09 
10 
11game.Players.PlayerAdded:Connect(function(player)
12    local color = Instance.new("IntValue")
13    color.Name = "BrickColorStore"
14    color.Parent = player
15 
View all 50 lines...

I don't know why you would need to get a value just to change the color of a part to a set color but I'm not you so I wouldn't know lol

0
Thank for helping, I know it's not a efficient way but I can take it :D ZombieApocalypz3 35 — 4y
Ad

Answer this question