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.
-
I’m trying to making it so it won’t interfere with my gameplay when i try to roll
-
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
-
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,
}
end
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
end
else
player:Kick("There Data Loading Error, Im so sorry but just rejoin :(")
end
end