Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

leaderboard datastore script indentation error?

I think this may just be me being stupid but I tried adding a death counter and messed up my script

local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")

local player = game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local collectibles = Instance.new("IntValue")
	collectibles.Name = "Collectibles"
	collectibles.Parent = leaderstats
	collectibles.Value = player.leaderstats.Collectibles.Value
	
	local deaths = Instance.new("IntValue")
	deaths.Name = "Deaths"
	deaths.Parent = leaderstats
	deaths.Value = player.leaderstats.Deaths.Value
	
	local level = Instance.new("IntValue")
	level.Name = "Level"
	level.Parent = leaderstats
	level.Value = 1
	
	player.RespawnLocation = workspace.Level1.L1Spawn
	
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:FindFirstChild("Humanoid")			
		
		humanoid.Died:Connect(function()
			
			deaths.Value = deaths.Value + 1
	
		end)
	end)
end)	
	
		local playerUserID = "Player_"..player.UserId
		
		local data
		local success, errormessage = pcall(function()
			data = myDataStore:GetAsync(playerUserID)
		end)
			
		if success then
			deaths.Value = data
	end	
end)

game.Players.PlayerRemoving:Connect(function(player)
	local playerUserID = "Player_"..player.UserId
	
	local data = player.leaderstats.Collectibles.Value
	
	local success, errormessage = pcall(function()
		myDataStore:SetAsync(playerUserID, data)
	end)
		
	if success then
		print("data saved")
	else
		print("data not saved")
		warn(errormessage)
	end

end)

2 comments

0

ServerScriptService.leaderboard:49: Expected , got 'end' i get this error

0

So I put the deaths script into a separate script, the death counter works now but doesn't save.

1 answer

✓ Accepted answer

I'm kinda new but if I'm not mistaken, if you got the error message "got 'end'", I believe this means that you have an extra end somewhere the doesn't correspond with a beginning

1 comment

0

I think it's line 48. I don't see anything that corresponds to that, try removing it and see if it works

This discussion is preserved as it was. New answers, comments, and votes are closed.