So basically for my game, I wanted to have a feature where you would buy a hat, and it would save. In line 16 of the script, there is a error I can't determine. If you are able to help, that would be very nice.
local DataStoreService = game:GetService("DataStoreService")
local PWStore = DataStoreService:GetDataStore("2602-2")
game.Players.PlayerAdded:Connect(function(player)
local CHat = Instance.new("StringValue")
CHat.Name = "CurrentHat"
CHat.Parent = player
local Data
local success, errormessage = pcall(function()
Data = PWStore:GetAsync(player.UserId.."-Hat")
end)
if success then
CHat.Value = Data
else
warn("There was an error getting data.")
print(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
PWStore:SetAsync(player.UserId.."-Hat",player.CHat.Value)
end)
if success then
print("Data Saved!")
else
warn("There was an error saving data.")
print(errormessage)
end
end)

1 comment
What´s the error_