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

Why wont this datastore work?

Asked by
LostPast 253 Moderation Voter
11 years ago
01local ds = game:GetService("DataStoreService"):GetDataStore("songlistNarwhalTEST")
02 
03function onTouched(hit)
04 check = hit.Parent:FindFirstChild("Humanoid")
05 if check ~= nil then
06  local charName = hit.Parent.Name
07 local key = "user_" .. charName
08 ds:SetAsync(key, 1)
09 end
10 end
11 
12script.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.

0
Sir, please put your code in a Code Block. M39a9am3R 3210 — 11y

1 answer

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
11 years ago
01local ds = game:GetService("DataStoreService"):GetDataStore("songlistNarwhalTEST")
02 
03function onTouched(hit)
04 check = hit.Parent:FindFirstChild("Humanoid")
05 if check ~= nil then
06 local charName = hit.Parent.Name
07 local key = "user_" .. charName
08 ds:SetAsync(key, 1)
09 end
10 end
11 
12script.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.

0
ds:GetAsync() errored to... It still is saying ds is a nil value for some stupid reason XD LostPast 253 — 11y
0
ds:GetAsync() errored to... It still is saying ds is a nil value for some stupid reason XD LostPast 253 — 11y
0
ds:GetAsync() errored to... It still is saying ds is a nil value for some stupid reason XD LostPast 253 — 11y
0
ds:GetAsync() errored to... It still is saying ds is a nil value for some stupid reason XD LostPast 253 — 11y
0
Could you stop spamming please? M39a9am3R 3210 — 11y
Ad

Answer this question