Why does this script fail?

		print("Data info:", "checkpoints:", checkpoints1.Value",")
		print("chapters:", chapters.Value",")
		print("temp", temp.Value)

this is the error: ServerScriptService.SavingScript:32: attempt to call a number value
the values exist. it prints it to output for debugging or for the player to know their values.
line 32 is the first print.

Could you include a bigger snippet of your code? We can’t just fix it based on 3 print lines.

Also, you forgot to concatenate the prints though:

print("Data info:", "checkpoints:", checkpoints1.Value ..",")
print("chapters:", chapters.Value ..",")
print("temp", temp.Value)

it has waits and line 32 is the first print. there is nothing really else that is important other than the instance.new stuff which creates a folder and creates and puts the values inside of it.

Could you just show the entire script? You probably did something wrong on one of those lines which is why the error is occuring.

game.Players.PlayerAdded:Connect(function(player)

	local leadstats = Instance.new("Folder")
	leadstats.Name = "leaderstats"
	local checkpoints1 = Instance.new("IntValue", leadstats)
	checkpoints1.Name = "Checkpointch1"
	local temp = Instance.new("IntValue", leadstats)
	temp.Name = "temp"
	local chapters = Instance.new("IntValue", leadstats)
	chapters.Name = "chapters"

	local playerUserId = "Player_"..player.UserId
	leadstats.Parent = player

	local success,save = pcall(function()
		return  data:GetAsync(playerUserId)
	end)
	
	if success then
		
		checkpoints1.Value = save['checkpoints1'] or 1
		chapters.Value = save['chapters'] or 1 
		print("data loaded")
		print("Data info:", "checkpoints:", checkpoints1.Value",")
		print("chapters:", chapters.Value",")
		print("temp", temp.Value)

Try this:

game.Players.PlayerAdded:Connect(function(player)
	local playerUserId = "Player_"..player.UserId

	local leadstats = Instance.new("Folder")
	leadstats.Name = "leaderstats"
	
	local checkpoints1 = Instance.new("IntValue")
	checkpoints1.Name = "Checkpointch1"
	checkpoints1.Parent = leadstats
	
	local temp = Instance.new("IntValue")
	temp.Name = "temp"
	temp.Parent = leadstats
	
	local chapters = Instance.new("IntValue")
	chapters.Name = "chapters"
	chapters.Parent = leadstats

	leadstats.Parent = player

	local success,save = pcall(function()
		return data:GetAsync(playerUserId)
	end)

	if success then
		checkpoints1.Value = save.checkpoints1 or 1
		chapters.Value = save.chapters or 1 
		
		print("data loaded")
		print("Data info:", "checkpoints:", checkpoints1.Value ..",")
		print("chapters:", chapters.Value ..",")
		print("temp", temp.Value)
	end
end)

your problem is here, on the first line:

(as well as the second line, but the same error is thrown here)

You’ve referenced a value, and followed it with direct speech marks. This is being recognised as an attempt to call a function, one of Lua’s many quirks.

To fix it, separate your values / variables and your strings:

        print("Data info:", "checkpoints:", checkpoints1.Value, ",")
		print("chapters:", chapters.Value ,",")
		print("temp", temp.Value)
1 Like