One Time Touch
Leaderstats (ServerScriptService)
local function onPlayerJoin(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
local completed = Instance.new('Folder')
completed.Name = 'completed'
completed.Parent = player
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
Script for Part
local level = script.Parent
local function level_complete(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
local completed_folder = player.completed
local alreadyCompleted = completed_folder:FindFirstChild(level.Name)
if not alreadyCompleted then
local level_name = Instance.new('StringValue')
level_name.Name = level.Name
level_name.Parent = completed_folder
player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
end
end
end
level.Touched:Connect(level_complete)