Board Thread:Roblox help and discussion/@comment-34860805-20190824102239

Hello I have been developing a game however sometimes there have been infernal flaws that I have been able to fix however this flaw so far I have not been able to fix. I made a leaderboard that has 3 things in it: DataStore, The cash type and what doesn't work is the kill player for cash. Here is the script I made:

local DataStoreService = game:GetService("DataStoreService")

local myDataStore = DataStoreService:GetDataStore("myDataStore")

game.Players.PlayerAdded:Connect(function(player)

local leaderstats = Instance.new("Folder")

leaderstats.Name = "leaderstats"

leaderstats.Parent = player

local cash = Instance.new("IntValue")

cash.Name = "Robuxs"

cash.Parent = leaderstats

cash.Value = 0

-- kill money

player.CharacterAdded:connect(function(character)

character:WaitForChild("Humanoid").Died:connect(function

local tag = character.Humanoid:FindFirstChild("creator")

if tag ~= nil then

if tag.Value ~= nil then

cash.Value = cash.Value + 10 --This is the reward after the player died.

end

end

end)

end)

-- kill money

local data

local success, errormessage = pcall(function

data = myDataStore:GetAsync(player.UserId.."-cash")

end)

if success then

cash.Value = data

else

print("Debug Message: For unknow reaseons your money stats was loose or server cannot find,This can be because the server apis are turned off for unknown reasons, try logging into another server and if the error continues like this contact a helper or the creator.")

warn(errormessage)

end

end)

game.Players.PlayerRemoving:Connect(function(player)

local success, errormessage = pcall(function

myDataStore:SetAsync(player.UserId.."-cash",player.leaderstats.Robuxs.Value)

end)

if success then

print("Debug Message: Your money stats was saved!!!")

else

print("Debug Message: For unknow reaseons your money stats dont saved, if you read this message contact the Helper or Creator.")

warn(errormessage)

end

end)

Where are the words kill money is this the part where it doesn't work, any way to fix this error? 