Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

i got error Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters?

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)

9 comments

0

what line is the error at?

0

10

0

Datastores can only hold strings, booleans etc..

0

Just by looking at it, it seems the argument of :SetAsync is missing

0

SetAsync requires another argument which is the value. cars_store is the variable

0

did you try my answer? 

0

also what do you want the script to do?

0

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.

0

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

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.