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

I have the error W001: Unknow global 'Player'?

I've been trying to make a Save Data system (If someone could help me with that too) because any of what i've tryied worked then i tryied with some YT videos and while i was copying the script (I write them) i saw this error, the script is..

  1. local Pitote = game:GetService("DataStoreService"):GetDataStore("Pitote")
  2. local Pito = Pitote:GetDataStore("Condon")
  3. game.Players.PlayerAdded:Connect(function(Player)
  4. local Piernas = Instance.new("Folder", Player)
  5. Piernas.Name = "leaderstats"
  6. local Coins = Instance.new("IntValue", Player)
  7. Coins.Name = "Coins"
  8. Coins.Value = Pito:GetAsync(Player.UserId) or 0
  9. Coins.Changed:Connect(function()
  10. Pito:SetAsync(Player.UserId, Coins.Value)
    
  11. end)
  12. end)
  13. game.Player.PlayerRemoving:Connect(function()
  14. Pito:SetAsync(Player.UserId, Player.Piernas.Coins.Value)
  15. end)

The error ocurrs on line 17 "(Player.UserId and Player.Piernas)" Any help?

1 comment

0

line 16: make it :Connect(function(Player), your did not add it there so the script does not know what is a player

2 answers

✓ Accepted answer
local Pitote = game:GetService("DataStoreService"):GetDataStore("Pitote")
local Pito = Pitote:GetDataStore("Condon")
game.Players.PlayerAdded:Connect(function(Player)
local Piernas = Instance.new("Folder", Player)
Piernas.Name = "leaderstats"
local Coins = Instance.new("IntValue", Player)
Coins.Name = "Coins"
Coins.Value = Pito:GetAsync(Player.UserId) or 0
Coins.Changed:Connect(function()
Pito:SetAsync(Player.UserId, Coins.Value)
end)
end)
game.Player.PlayerRemoving:Connect(function(Player) -- You forgot to put Player in the parameter
Pito:SetAsync(Player.UserId, Player.Piernas.Coins.Value)
end)

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