Score board

local Players = game:GetService("Players")
local PointsService = game:GetService("PointsService")

function onPlayerAdded(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
end

function onPlayerRemoving(player)
PointsService:SetPoints(player.UserId, player.leaderstats.Points.Value)
end

Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)

This code creates a folder named “leaderstats” for each player that joins the game. It also creates an IntValue named “Points” inside the folder and sets its value to 0. When a player leaves the game, the code saves their points using the PointsService2.

I hope this helps! Let me know if you have any other questions

By:


Leave a comment

Design a site like this with WordPress.com
Get started