Greetings Guys! I have made a game where when you kill an enemy, you get points in datastores.
somehow the datastore variable does not change it. For example, if I have 50 dollars, no matter how many times I kill it, I will only have 100 dollars. How do I fix this?
code:
local Players = game:GetService("Players");
script.Parent.Humanoid.Died:Connect(function()
local playerWhoKilled = script.Parent.Humanoid:WaitForChild("creator").Value
print(playerWhoKilled)
local cash = Players:FindFirstChild(playerWhoKilled.Name).data.cash.Value
cash = cash + 50
print(cash)
Players:FindFirstChild(playerWhoKilled.Name).PlayerGui.BaseGUI.Money.Text = cash .. "$"
end)
I don’t need help in any other part, just where you give the player the money.