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

Why wont this datastore work?

local ds = game:GetService("DataStoreService"):GetDataStore("songlistNarwhalTEST")

function onTouched(hit)
 check = hit.Parent:FindFirstChild("Humanoid")
 if check ~= nil then
  local charName = hit.Parent.Name
 local key = "user_" .. charName
 ds:SetAsync(key, 1)
 end
 end

script.Parent.Touched:connect(onTouched)

For some reason it says ds is a nil value and it doesn't work in game... Does anyone know how to fix this script and make it work? Thank you for your help.

1 comment

0

Sir, please put your code in a Code Block.

1 answer

local ds = game:GetService("DataStoreService"):GetDataStore("songlistNarwhalTEST")

function onTouched(hit)
 check = hit.Parent:FindFirstChild("Humanoid")
 if check ~= nil then
 local charName = hit.Parent.Name
 local key = "user_" .. charName
 ds:SetAsync(key, 1)
 end
 end

script.Parent.Touched:connect(onTouched)

I see no errors in your code. It looks like it should save properly. Have you tried GetAsync? It's what loads your key.

5 comments

0

ds:GetAsync() errored to... It still is saying ds is a nil value for some stupid reason XD

0

ds:GetAsync() errored to... It still is saying ds is a nil value for some stupid reason XD

0

ds:GetAsync() errored to... It still is saying ds is a nil value for some stupid reason XD

0

ds:GetAsync() errored to... It still is saying ds is a nil value for some stupid reason XD

0

Could you stop spamming please?

This discussion is preserved as it was. New answers, comments, and votes are closed.