Hello there, can someone help me do script for obby. I want do stages and deaths leaderboard but I'm new at scripting and It's not working if anyone know how to do it pls reply or message me on discord naprcanejkoren#1704

the code is

local dss = game:GetService("DataStoreService")
local obbyDS = dss:GetDataStore("ObbyData")
local deathsDS = dss:GetDataStore("DeathsData")

local checkpoints = workspace.Checkpoints


game.Players.PlayerAdded:Connect(function(plr)
	
	local obbyData = obbyDS:GetAsync(plr.UserId .. "-obbyStageProgress")
	local deathsData = deathsDS:GetAsync(plr.UserId .. "-deaths")	

	local ls = Instance.new("Folder")
	ls.Name = "leaderstats"
	ls.Parent = plr
	
	local stage = Instance.new("StringValue")
	stage.Name = "Stage"
	stage.Value = obbyData or 1
	stage.Parent = ls

	local wipeouts = Instance.new("IntValue")  
        wipeouts.Name = "Deaths"
        wipeouts.Value = deathsData or 0
    	wipeouts.Parent = ls
	
	local char = plr.Character or plr.CharacterAdded:Wait()
	
	char:WaitForChild("HumanoidRootPart").CFrame = checkpoints[stage.Value].CFrame
	
	char.Humanoid.Touched:Connect(function(touch)
				
		if touch.Parent == checkpoints then
			if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
				stage.Value = touch.Name
					
				pcall(function()
			
					obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
				end)
			end
		end
	end)
	char.Humanoid.Died:Connect(function()
           
           	wipeouts.Value = wipeouts.Value + 1
		deathsDS:SetAsync(plr.UserId .. "-deaths", plr.leaderstats.Deaths.Value)
           
        end) 
	
	plr.CharacterAdded:Connect(function(char)
		
		local hrp = char:WaitForChild("HumanoidRootPart")		
		local humanoid = char:WaitForChild("Humanoid")
			
		hrp:GetPropertyChangedSignal("CFrame"):Wait()

		hrp.CFrame = checkpoints[stage.Value].CFrame
		
		humanoid.Touched:Connect(function(touch)
				
			if touch.Parent == checkpoints then
				if (tonumber(touch.Name) and tonumber(touch.Name) > tonumber(stage.Value)) or touch.Name == "End" then
					stage.Value = touch.Name
					
					pcall(function()
			
						obbyDS:SetAsync(plr.UserId .. "-obbyStageProgress", plr.leaderstats.Stage.Value)
					end)
				end
			end
		end)

	end)	
end)

deaths start on line 44 i think

4 comments

0

This is a place to ask for help on scripts not asking for people to work / help you on games.

0

I have my own script but the deaths dont count.

0

Post the script in lua block so we can see the problem you have and fix it instead of making new one. Also this is off-topic but i speak slovan language and your name is innaproniate so consider changing it.

0

ok i posted code