Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players=game:GetService("Players")
- local ReplicatedStorage=game:GetService("ReplicatedStorage")
- local DataStoreService=game:GetService("DataStoreService")
- local HttpService=game:GetService("HttpService")
- local RunService=game:GetService("RunService")
- local Config
- do
- local ok,mod=pcall(function()return require(ReplicatedStorage:WaitForChild("Config"))end)
- Config=(ok and type(mod)=="table") and mod or {
- AllowCheckpointSkip=false,
- SummitReward=1,
- WebhookURL="",
- OwnerUsernames={},
- AdminUsernames={}
- }
- end
- local CheckpointData=DataStoreService:GetDataStore("SummitStoreV1")
- local touchCooldown={}
- local function safeGet(key)
- local tries=0
- while tries<3 do
- local ok,res=pcall(function()return CheckpointData:GetAsync(key)end)
- if ok then return res end
- tries+=1
- task.wait(0.4)
- end
- return nil
- end
- local function safeSet(key,value)
- local tries=0
- while tries<3 do
- local ok=pcall(function()CheckpointData:SetAsync(key,value)end)
- if ok then return true end
- tries+=1
- task.wait(0.4)
- end
- return false
- end
- local function ensureRemote(name)
- local r=ReplicatedStorage:FindFirstChild(name)
- if r and r:IsA("RemoteEvent") then return r end
- local new=Instance.new("RemoteEvent")
- new.Name=name
- new.Parent=ReplicatedStorage
- return new
- end
- local CP_Success=ensureRemote("CP_Success")
- local CP_Fail=ensureRemote("CP_Fail")
- local Summit_Success=ensureRemote("Summit_Success")
- local RunCommandEvent=ensureRemote("RunControlCommand")
- local checkpointsFolder=workspace:FindFirstChild("Checkpoints")
- local summitPart=workspace:FindFirstChild("Summit")
- local fallFolder=workspace:FindFirstChild("FallParts")
- local startSpawnPart=workspace:FindFirstChild("StartSpawn")
- if not checkpointsFolder then error("[CheckpointSystem] Missing Checkpoints") end
- if not summitPart then error("[CheckpointSystem] Missing Summit") end
- local START_SPAWN_LOCATION=Vector3.new(0,5,0)
- if startSpawnPart and startSpawnPart:IsA("BasePart") then
- START_SPAWN_LOCATION=startSpawnPart.Position+Vector3.new(0,5,0)
- end
- local function isAdmin(player)
- local name=(player.Name or tostring(player)):lower()
- for _,v in ipairs(Config.OwnerUsernames or {}) do
- if type(v)=="string" and name==v:lower() then return true end
- end
- for _,v in ipairs(Config.AdminUsernames or {}) do
- if type(v)=="string" and name==v:lower() then return true end
- end
- return false
- end
- Players.PlayerAdded:Connect(function(plr)
- plr.CharacterAdded:Connect(function(char)
- local ok,h=pcall(function()return char:WaitForChild("Humanoid",5)end)
- if ok and h then h.DisplayDistanceType=Enum.HumanoidDisplayDistanceType.None end
- end)
- end)
- local checkpoints={}
- for _,c in ipairs(checkpointsFolder:GetChildren()) do
- if c:IsA("BasePart") then table.insert(checkpoints,c) end
- end
- local function getIndexFromName(name)
- local n=name and name:match("%d+")
- return n and tonumber(n) or math.huge
- end
- table.sort(checkpoints,function(a,b)
- return getIndexFromName(a.Name)<getIndexFromName(b.Name)
- end)
- local COLOR_PASSED=Color3.fromRGB(0,255,0)
- local COLOR_UNPASSED=Color3.fromRGB(255,0,0)
- local function teleportToCheckpoint(player,force)
- local cpIndex=player:GetAttribute("Checkpoint") or 0
- local pos
- if force then
- pos=(cpIndex>0 and checkpoints[cpIndex] and checkpoints[cpIndex].Position+Vector3.new(0,2,0))
- or ((startSpawnPart and startSpawnPart:IsA("BasePart")) and startSpawnPart.Position+Vector3.new(0,5,0)
- or START_SPAWN_LOCATION)
- else
- pos=(cpIndex>0 and checkpoints[cpIndex] and checkpoints[cpIndex].Position+Vector3.new(0,2,0))
- or START_SPAWN_LOCATION
- end
- local char=player.Character
- if not char then return end
- local hrp=char:FindFirstChild("HumanoidRootPart")
- if hrp then
- local old=hrp.Anchored
- hrp.Anchored=true
- hrp.CFrame=CFrame.new(pos)
- task.delay(0.2,function()if hrp then hrp.Anchored=old end end)
- elseif char.PrimaryPart then
- local pp=char.PrimaryPart
- local old=pp.Anchored
- pp.Anchored=true
- char:SetPrimaryPartCFrame(CFrame.new(pos))
- task.delay(0.2,function()if pp then pp.Anchored=old end end)
- end
- end
- local function setupPlayer(player)
- local ls=player:FindFirstChild("leaderstats")
- if not ls then
- ls=Instance.new("Folder",player)
- ls.Name="leaderstats"
- local cp=Instance.new("IntValue",ls)
- cp.Name="Checkpoint"
- cp.Value=0
- local sm=Instance.new("NumberValue",ls)
- sm.Name="Summit"
- sm.Value=0
- end
- local data=safeGet(player.UserId)
- local lastCP=(data and data.LastCheckpoint) or 0
- local totalSummit=(data and data.TotalSummit) or 0
- ls.Checkpoint.Value=lastCP
- ls.Summit.Value=totalSummit
- player:SetAttribute("Checkpoint",lastCP)
- player:SetAttribute("RunStartTime",os.time())
- for i,cp in ipairs(checkpoints) do
- cp.BrickColor=BrickColor.new(i<=lastCP and COLOR_PASSED or COLOR_UNPASSED)
- end
- player.CharacterAdded:Connect(function()
- task.wait(0.1)
- teleportToCheckpoint(player)
- end)
- end
- Players.PlayerAdded:Connect(setupPlayer)
- Players.PlayerRemoving:Connect(function(player)
- if not player then return end
- local summitVal=player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Summit")
- local cpVal=player:GetAttribute("Checkpoint")
- if summitVal and cpVal~=nil then
- pcall(function()
- safeSet(player.UserId,{
- LastCheckpoint=cpVal,
- TotalSummit=summitVal.Value
- })
- end)
- end
- end)
- for i,cp in ipairs(checkpoints) do
- if not cp then continue end
- cp.Touched:Connect(function(hit)
- local player=Players:GetPlayerFromCharacter(hit.Parent)
- if not player then return end
- if touchCooldown[player] then return end
- touchCooldown[player]=true
- task.delay(1,function() touchCooldown[player]=nil end)
- local currentCP=player:GetAttribute("Checkpoint") or 0
- if not Config.AllowCheckpointSkip then
- if i<=currentCP then return end
- if i>currentCP+1 then
- CP_Fail:FireClient(player)
- return
- end
- else
- if i<=currentCP then return end
- end
- player:SetAttribute("Checkpoint",i)
- if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Checkpoint") then
- player.leaderstats.Checkpoint.Value=i
- end
- cp.BrickColor=BrickColor.new(COLOR_PASSED)
- CP_Success:FireClient(player,i)
- pcall(function()
- safeSet(player.UserId,{
- LastCheckpoint=i,
- TotalSummit=player.leaderstats and player.leaderstats.Summit and player.leaderstats.Summit.Value or 0
- })
- end)
- end)
- end
- if summitPart then
- summitPart.Touched:Connect(function(hit)
- local player=Players:GetPlayerFromCharacter(hit.Parent)
- if not player then return end
- if touchCooldown[player] then return end
- touchCooldown[player]=true
- task.delay(1.2,function() touchCooldown[player]=nil end)
- local totalCP=#checkpoints
- local currentCP=player:GetAttribute("Checkpoint") or 0
- if currentCP<totalCP then
- CP_Fail:FireClient(player)
- return
- end
- local startTime=player:GetAttribute("RunStartTime") or os.time()
- local endTime=os.time()
- local duration=math.max(0,endTime-startTime)
- local h=math.floor(duration/3600)
- local m=math.floor((duration%3600)/60)
- local s=duration%60
- local formattedTime=string.format("%02d:%02d:%02d",h,m,s)
- local date=os.date("%Y-%m-%d %H:%M:%S",endTime)
- local profileLink="https://www.roblox.com/users/"..player.UserId.."/profile"
- local summitStat=player.leaderstats and player.leaderstats:FindFirstChild("Summit")
- if summitStat then summitStat.Value=summitStat.Value+(Config.SummitReward or 1) end
- player:SetAttribute("Checkpoint",0)
- if player.leaderstats and player.leaderstats:FindFirstChild("Checkpoint") then
- player.leaderstats.Checkpoint.Value=0
- end
- player:SetAttribute("RunStartTime",os.time())
- for _,cp in ipairs(checkpoints) do
- if cp and cp:IsA("BasePart") then
- cp.BrickColor=BrickColor.new(COLOR_UNPASSED)
- end
- end
- Summit_Success:FireClient(player)
- pcall(function()
- safeSet(player.UserId,{
- LastCheckpoint=0,
- TotalSummit=summitStat and summitStat.Value or 0
- })
- end)
- local webhook=Config.WebhookURL
- if webhook~="" then
- task.spawn(function()
- local embed={
- username="Summit Logs",
- avatar_url="https://i.imgur.com/keJaZ9P.png",
- embeds={{
- title="🏔️ Summit Monitoring! by tt@sukitovone",
- color=16762624,
- fields={{
- {name="Username",value=player.Name,inline=true},
- {name="Display Name",value=player.DisplayName,inline=true},
- {name="User ID",value=tostring(player.UserId),inline=true},
- {name="Roblox Profile",value="["..player.Name.."]("..profileLink..")",inline=false},
- {name="Total Summits",value=tostring(summitStat and summitStat.Value or 0),inline=true},
- {name="Run Duration",value=formattedTime,inline=true},
- {name="Time Reached",value=date,inline=false}
- }}
- }}
- }
- local ok,err=pcall(function()
- HttpService:PostAsync(webhook,HttpService:JSONEncode(embed),Enum.HttpContentType.ApplicationJson)
- end)
- if not ok then warn("Webhook error:",err) end
- end)
- end
- end)
- end
- if fallFolder then
- for _,part in ipairs(fallFolder:GetChildren()) do
- if part:IsA("BasePart") then
- part.Touched:Connect(function(hit)
- local player=Players:GetPlayerFromCharacter(hit.Parent)
- if player then teleportToCheckpoint(player,true) end
- end)
- end
- end
- end
- RunCommandEvent.OnServerEvent:Connect(function(player,command,targetName,amount)
- if not isAdmin(player) then
- RunCommandEvent:FireClient(player,"Notification","❌ Gagal: Bukan admin",Color3.fromRGB(255,0,0))
- return
- end
- if command=="AdjustSummit" and type(amount)=="number" then
- local target=Players:FindFirstChild(targetName)
- if not target then
- RunCommandEvent:FireClient(player,"Notification","⚠️ Pemain "..targetName.." tidak ditemukan",Color3.fromRGB(255,0,0))
- return
- end
- local stat=target.leaderstats and target.leaderstats:FindFirstChild("Summit")
- if stat then
- stat.Value=stat.Value+amount
- pcall(function()
- safeSet(target.UserId,{
- LastCheckpoint=target:GetAttribute("Checkpoint"),
- TotalSummit=stat.Value
- })
- end)
- local action=amount>=0 and "ditambahkan" or "dikurangi"
- RunCommandEvent:FireClient(
- player,
- "Notification",
- string.format("✅ Summit %s %.1f untuk %s (Total: %.1f)",action,math.abs(amount),targetName,stat.Value),
- Color3.fromRGB(0,200,0)
- )
- else
- RunCommandEvent:FireClient(player,"Notification","❌ Leaderstat 'Summit' tidak ditemukan",Color3.fromRGB(255,0,0))
- end
- end
- end)
- print("[Checkpoint System Integrated Successfully! Fixed for Publish]")
Advertisement
Add Comment
Please, Sign In to add comment