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...
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.