Leaderstats Error Problem: Attempt to index nil with 'Linked Sword'

So, I need help with a script i was making and it been going on for somewhat a long time i guess but it been interfering with my gameplay and data saving.

  1. I’m trying to making it so it won’t interfere with my gameplay when i try to roll

  2. Every time I play and roll it fine but when I rejoin, my items are gone. So I dont know if that piece been causing it. This is the error everytime I rejoin ServerScriptService.leaderstats:61: attempt to index nil with 'Linked Sword' - Server - leaderstats:61

  3. I hadn’t try to solution yet because I don’t know what to do.

This is a piece of code I have with the code

	if success then
		if returnValue == nil then
			returnValue = {
				Rolls = 0,
		player.leaderstats.Rolls.Value = if returnValue.Rolls ~= nil then returnValue.Rolls else 0
		player.Inventory.EquippedChance.Value = if returnValue.EquippedChance ~= nil then returnValue.EquippedChance else "None"
		for i, v in pairs(player.Inventory.OwnedChances:GetChildren()) do
			v.Value = if returnValue.Inventory.OwnedChances[v.Name] ~= nil then returnValue.Inventory.OwnedChances[v.Name] else false -- This is the part where the error happens
		player:Kick("There Data Loading Error, Im so sorry but just rejoin :(")

I found the problem, I just realized it wasn’t that hard but I was just being dumb :skull:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.