Auto Give Points

Leaderstats

local function onPlayerJoin(player)

local leaderstats = Instance.new('Folder')

leaderstats.Name = 'leaderstats'

leaderstats.Parent = player

local money = Instance.new('IntValue')

money.Name = 'Money'

money.Value = 0

money.Parent = leaderstats

end


game.Players.PlayerAdded:Connect(onPlayerJoin)

AutoPoints

local amount = 5

local giveTime = 3


while true do

wait(giveTime)

for _,plr in pairs(game.Players:GetChildren()) do

local stats = plr:FindFirstChild('leaderstats')

if stats then

stats.Money.Value = stats.Money.Value + amount

end

end

end

Leaderstats (DataStore Version)

local DataStoreService = game:GetService("DataStoreService")

local playerData = DataStoreService:GetDataStore("PlayerData")


local function onPlayerJoin(player) -- Runs when players join


local leaderstats = Instance.new("Folder") --Sets up leaderstats folder

leaderstats.Name = "leaderstats"

leaderstats.Parent = player


local money = Instance.new("IntValue") --Sets up value for leaderstats

money.Name = "Money"

money.Parent = leaderstats


local playerUserId = "Player_" .. player.UserId --Gets player ID

local data = playerData:GetAsync(playerUserId) --Checks if player has stored data

if data then

-- Data exists for this player

money.Value = data

else

-- Data store is working, but no current data for this player

money.Value = 0

end


end


local function onPlayerExit(player) --Runs when players exit


local success, err = pcall(function()

local playerUserId = "Player_" .. player.UserId

playerData:SetAsync(playerUserId, player.leaderstats.Money.Value) --Saves player data

end)


if not success then

warn('Could not save data!')

end

end


game.Players.PlayerAdded:Connect(onPlayerJoin)

game.Players.PlayerRemoving:Connect(onPlayerExit)