So I have a simple enough question. I have made a datastore in the following script but for some reason when the player dies it does not save the player lives. Can someone please tell me what im doing wrong. Any help is greatly appreciated
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local PlayerLives = DataStoreService:GetDataStore("PlayerLives")
player = script.Parent.Parent.Parent.Parent
YourPlayer = player.Name
PlayerName = {YourPlayer}
local Reward = game.ReplicatedStorage.Reward:WaitForChild(PlayerName[1])
Reward.Changed:connect(function(plr)
print ("The Number Value Is Working")
print("Lives are Zero")
print(plr)
pcall(function()
PlayerLives:SetAsync("PLives", plr)
end)
local Lives = PlayerLives:GetAsync("PLives")
print(Lives)
RewardV = Reward.Value
local LivesLeft = Lives + RewardV
print(LivesLeft)
pcall(function()
PlayerLives:SetAsync(player "PLives", LivesLeft)
end)
Number = script.Parent.Number
Number.Text = LivesLeft
end)
