Trying to create a cash for kill system for my game
This is my datastores script
local DataStore = game:GetService("DataStoreService")
local moneydata = DataStore:GetDataStore("Coin")
game.Players.PlayerAdded:Connect(function(player)
local playerKey = "Player_" .. player.UserId
local data = Instance.new("Folder", player)
data.Name = "Data"
local money = Instance.new("IntValue")
money.Parent = data
money.Name = "Money"
local myMoney
local success, err = pcall(function()
myMoney = moneydata:GetAsync(playerKey)
end)
if success then
money.Value = myMoney
else
money.Value = 250
end
if money.Value < 0 then
money.Value = 0
end
money.Value = moneydata:GetAsync(player.UserId) or 250
moneydata:SetAsync(player.UserId, money.Value)
money.Changed:connect(function()
print("Saving data...")
moneydata:SetAsync(player.UserId, money.Value)
print(player.UserId.."'s data has been saved!")
end)
end)
What do I need to do to detect kills and give a player money per kill?
Hey, here is a tutorial that explains exactly how to do that. In the future, try doing a quick search to see if anything is similar to your topic, as there are many sources which can assist you.