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

Why is it underlining my player variable?

local ds = game:GetService("DataStoreService")
local ds1 = ds:GetDataStore("PostionSavingSystem")

game.Players.PlayerAdded:Connect(function(players)
 local val = Instance.new("Vector3Value", players)
 val.Name = "Position"
 
 local userdata
 pcall(function()
  userdata = ds1:GetAsync(player.UserId)
  
 end)
 if userdata then
 game.Workspace:WaitForChild(player.Name):WaitForChild("HumanoidRootPart").CFrame = CFrame.new(userdata.x, userdata.y, userdata.z)
 else
  ds1:SetAsync(player.UserId,{
   x = 0,
   y = 3,
   z = 0,
  }) 
 end
end)

game.Players.PlayerRemoving:Connect(function(player)
 ds1:SetAysnc(player.UserId, {
  x = player.Position.Value.X,
  y = player.Position.Value.Y,
  z = player.Position.Value.Z,
 })
end)

the game is saying underlining only player, its also saying SetAysnc is not a valid member of GlobalDataStore but it is???

1 comment

0

GlobalDataStore:SetAsync(); Not GlobalDataStore:SetAysnc() improper spelling. Its depreciated

1 answer

Like @voidofdeathfire said; you misspelled SetAsync(). But you also put a comma at the end of your table which ruined your script.

local ds = game:GetService("DataStoreService")
local ds1 = ds:GetDataStore("PostionSavingSystem")

game.Players.PlayerAdded:Connect(function(players)
 local val = Instance.new("Vector3Value", players)
 val.Name = "Position"

 local userdata
 pcall(function()
  userdata = ds1:GetAsync(player.UserId)

 end)
 if userdata then
 game.Workspace:WaitForChild(player.Name):WaitForChild("HumanoidRootPart").CFrame = CFrame.new(userdata.x, userdata.y, userdata.z)
 else
  ds1:SetAsync(player.UserId,{
   x = 0,
   y = 3,
   z = 0
  }) 
 end
end)

game.Players.PlayerRemoving:Connect(function(player)
 ds1:SetAsync(player.UserId, {
  x = player.Position.Value.X,
  y = player.Position.Value.Y,
  z = player.Position.Value.Z
 })
end)

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