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

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

Asked by 4 years ago

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?

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

2 answers

Log in to vote
0
Answered by
rabbi99 714 Moderation Voter
4 years ago
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)
Ad
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

Data Stores are quite easy once you've done them a few times. Here's a helpful post!

https://developer.roblox.com/en-us/articles/Data-store

Answer this question