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

Why is it underlining my player variable?

Asked by 5 years ago
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???

0
GlobalDataStore:SetAsync(); Not GlobalDataStore:SetAysnc() improper spelling. Its depreciated voidofdeathfire 148 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
Ad

Answer this question