local DSS = game:GetService("DataStoreService")
local cars_store = DSS:GetDataStore("player_cars")
local SS = game:GetService("ServerStorage")
local dealer = game.Workspace.dealer
function spawn_car(player)
local player_id = player.UserId -- idk what to add next
print(player_id)
cars_store:SetAsync(player_id, cars_store)
end
dealer.head.ProximityPrompt.Triggered:Connect(spawn_car)
COMMUNITY QUESTION
i got error Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters?
1 answer
I haven't tested this out. But by looking at it it seems that in line 10, you're missing a value. The script is expecting an argument, but it got an instance which is cars_store in this case.
Simply replace this:
cars_store:SetAsync(player_id, cars_store)
With this:
cars_store:SetAsync(player_id, 50) --change 50 to ur value name
(EDIT:)
Also, don't forget to reference the player!
Full script:
local player = game.Players.PlayerAdded:Connect(function(player)
local DSS = game:GetService("DataStoreService")
local cars_store = DSS:GetDataStore("player_cars")
local SS = game:GetService("ServerStorage")
local dealer = game.Workspace.dealer
function spawn_car(player)
local player_id = player.UserId -- idk what to add next
print(player_id)
cars_store:SetAsync(player_id, 50)
end
end)
dealer.head.ProximityPrompt.Triggered:Connect(spawn_car)
If you need any more assistance, ask and I'll try to help you.
####JesseSong!
1 comment
0
also, do let me know if you have more issues.
This discussion is preserved as it was. New answers, comments, and votes are closed.

9 comments
what line is the error at?
10
Datastores can only hold strings, booleans etc..
Just by looking at it, it seems the argument of :SetAsync is missing
SetAsync requires another argument which is the value. cars_store is the variable
did you try my answer?
also what do you want the script to do?
since you aren't being that descriptive in your question, i don't know what you want to accomplish, so i can't really help you properly.
make sure your question is well - descriptive. see this to learn how to post good questions/answers: https://scriptinghelpers.org/help/how-post-good-questions-answers