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

GetAsync is not a valid member of datastoreservice?,help!

I'm trying to a script that checks if player has that in data but its not working! heres script:

local DS = game:GetService("DataStoreService")
local NewPlayerValueName = "NewPlayer"
local RS = game:GetService("ReplicatedStorage")
local Remote = RS.TutorialFinish

game.Players.PlayerAdded:Connect(function(plr)
	if DS:GetAsync("TFinish")[plr.Name] then
		plr.PlayerGui.Finish.Visible = false
		plr.PlayerGui.Tutorial.Visible = false
		plr.PlayerGui.Tutorial2.Visible = false
		plr.PlayerGui.Tutorial3.Visible = false
	end
end)

Remote.OnServerEvent:connect(function(plrname)
	DS:SetAsync("TFinish",{plrname})
end)

thx for looking...

9 comments

0

Im confused why you made a variable thats longer than what it holds.

0

GetAsync is a function of GlobalDataStore which you get by DataStoreService:GetDataStore(unique_key)

0

maybe he wanted to use it multiple times but if not, lol

0

oh k xd

0

Unless your GUI was made by the server this wont work.

0

Even if using something multiple times you'd still have to type more in the end.

0

local abcdefg = "abc" -- super gross and inefficient

0

if he were to want to change the value in the future it would only be once

0

Well he didnt even use it lol.

1 answer

✓ Accepted answer

In order to use datastores, you must require the service which you have done local DS = game:GetService("DataStoreService") and then from the datastore service, get the specific datastore you are looking for. For instance local MyDataStore = DS:GetDataStore('Datastore name here'), in which you are then looking inside of a datastore rather than looking in the service itself.

You should also make sure you are looking at a specifc players data when :GetAsync or otherwise it will be the same for all users. You can do this by adding in a prefix when you :GetAsync, for example MyDataStore:GetAsync(plr.UserId.."TFinish").

By adding in a prefix you must also change the saving process. I have edited this below.

Here is the updated code that should work:

local DS = game:GetService("DataStoreService")
local MyDataStore = DS:GetDataStore('Infomation')
local NewPlayerValueName = "NewPlayer"
local RS = game:GetService("ReplicatedStorage")
local Remote = RS.TutorialFinish
 
game.Players.PlayerAdded:Connect(function(plr)
	    if MyDataStore:GetAsync(plr.UserId.."TFinish") then
	        plr.PlayerGui.Finish.Visible = false
	        plr.PlayerGui.Tutorial.Visible = false
	        plr.PlayerGui.Tutorial2.Visible = false
                plr.PlayerGui.Tutorial3.Visible = false
	    end
	end)
	 
	Remote.OnServerEvent:connect(function(plrname)
	    MyDataStore:SetAsync(plrname.UserId.."TFinish", true)
	end)

I hope you also realise that by firing the Remote Event the Frames .Visible value will not change as it only works when the player joins the server, or rejoins for that matter.

1 comment

0

thanks

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