#gng when i check inventory theres only a rappier no wand pls help
1 messages · Page 1 of 1 (latest)
ok
yo chill
local DataStoreService = game:GetService("DataStoreService")
local RS = game:GetService("ReplicatedStorage")
local dataStoreExpEvent = RS.Events:FindFirstChild("DatastoreEXP")
local dataStoreMoneyEvent = RS.Events:FindFirstChild("DatastoreMoney")
local lvlStore = DataStoreService:GetDataStore("LVL")
local EXPStore = DataStoreService:GetDataStore("EXP")
local waveLootEvent = RS.Events:FindFirstChild("WaveLootReady")
local grantLootRE = RS.Events:FindFirstChild("GrantLoot")
local RarityMod = require(RS.Modules:FindFirstChild("RandomRarityEtc"))
local inventoryMod = require(RS.Modules:WaitForChild("PhysicalInventoryModule"))
local inventoryDataEvent = RS.Events:WaitForChild("SendInventoryData")
local inventoryDataStore = DataStoreService:GetDataStore("Inventory")
local moneyDataStore = DataStoreService:GetDataStore("Money")
TYY
no
soo
im making it easier to read for myself
oh ok
else
for i = 1, 1 do
local Rapier = RS.Items:FindFirstChild("Rapier"):Clone()
Rapier.Parent = player:FindFirstChild("InventoryFolder")
Rapier:SetAttribute("Rarity", RarityMod.GetRandomRarities())
Rapier.Name = "Rapier_" .. math.random()
inventoryMod.AddToPhysicalInventory(player, Rapier)
local Wand = RS.Items:FindFirstChild("Wand"):Clone()
Wand.Parent = player:FindFirstChild("InventoryFolder")
Wand:SetAttribute("Rarity", RarityMod.GetRandomRarities())
Wand.Name = "Wand" .. math.random()
inventoryMod.AddToPhysicalInventory(player, Wand)
end
end
UpdateInventory(player)
dataStoreExpEvent:Fire(player, exp, lvl, 0)
dataStoreMoneyEvent:Fire(player, money, 0)
playerStats.Parent = player
lvl.Parent = playerStats
exp.Parent = playerStats
money.Parent = playerStats
else
print("Something went wrong while loading your data")
end
UpdateInventory(player)
```
thes2e are the main linez
😭
lol
i thinking bro is making sure its right
lol
i think i see the problem
?
1,2?
😭
lol
i dont think ur adding the wand to their inventory bro
just the rapier
hold on let me actually look rq
add a print statement between these two lines and test
inventoryMod.AddToPhysicalInventory(player, Rapier)
local Wand = RS.Items:FindFirstChild("Wand"):Clone()
i would say use debugger to step thru addtophysicalinventory but if you dk how and dont wanna learn this works too
most ppl dk how
is inv empty?
wat should print say
@formal vector
its to see if the addtophysicalinventory function finishes running
kk
19:48:34.285 tempolate - Server - PhysicalInventoryModule:80
19:48:36.303 Infinite yield possible on 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler:WaitForChild("Reference")' - Studio
19:48:36.303 Stack Begin - Studio
19:48:36.303 Script 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler', Line 3 - Studio
19:48:36.303 Stack End - Studio
19:48:37.101 Infinite yield possible on 'Players.NexusBloxz:WaitForChild("isAttacking")' - Studio
19:48:37.101 Stack Begin - Studio
19:48:37.101 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.Ability1.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:48:37.101 Stack End - Studio
19:48:37.101 Infinite yield possible on 'Players.NexusBloxz:WaitForChild("isAttacking")' - Studio
19:48:37.101 Stack Begin - Studio
19:48:37.101 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.ClassAbility.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:48:37.101 Stack End - Studio
19:48:37.101 Infinite yield possible on 'Players.NexusBloxz:WaitForChild("isAttacking")' - Studio
19:48:37.101 Stack Begin - Studio
19:48:37.101 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.Ability3.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:48:37.101 Stack End - Studio
19:48:37.329 Infinite yield possible on 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler:WaitForChild("Reference")' - Studio
19:48:37.329 Stack Begin - Studio
19:48:37.329 Script 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler', Line 3 - Studio
19:48:37.329 Stack End - Studio
@formal vector
theres no hi
yo
whered u put the hi
else
for i = 1, 1 do
local Rapier = RS.Items:FindFirstChild("Rapier"):Clone()
Rapier.Parent = player:FindFirstChild("InventoryFolder")
Rapier:SetAttribute("Rarity", RarityMod.GetRandomRarities())
Rapier.Name = "Rapier_" .. math.random()
inventoryMod.AddToPhysicalInventory(player, Rapier)
print("hi")
local Wand = RS.Items:FindFirstChild("Wand"):Clone()
Wand.Parent = player:FindFirstChild("InventoryFolder")
Wand:SetAttribute("Rarity", RarityMod.GetRandomRarities())
Wand.Name = "Wand" .. math.random()
inventoryMod.AddToPhysicalInventory(player, Wand)
end
end
UpdateInventory(player)
dataStoreExpEvent:Fire(player, exp, lvl, 0)
dataStoreMoneyEvent:Fire(player, money, 0)
playerStats.Parent = player
lvl.Parent = playerStats
exp.Parent = playerStats
money.Parent = playerStats
else
print("Something went wrong while loading your data")
end
UpdateInventory(player)
```
show us the function you're calling in
local inventoryMod = require(RS.Modules:WaitForChild("PhysicalInventoryModule"))
print(typeof(inv), #inv) add this line after line 110 and lmk if it prints anything
local DataStoreService = game:GetService("DataStoreService")
local DS = DataStoreService:GetDataStore("PlayerInventory")
local module = {}
local Inventory = {}
local maxSlots = 50
local function getKey(userId)
return "Inventory_" .. userId
end
function module.LoadInventory(userId)
local key = getKey(userId)
local success, data = pcall(function()-- data is the returned value
return DS:GetAsync(key)
end)
if success and type(data) == "table" then
Inventory[userId] = data
else
Inventory[userId] = {}
end
for i = 1, maxSlots do
Inventory[userId][i] = Inventory[userId][i]
end
end
function module.SaveInventory(userId)
local key = getKey(userId)
local data = Inventory[userId] or {}
pcall(function()
DS:SetAsync(key, data)
end)
end
function module.CreateInventory(userId)
if not Inventory[userId] then
module.LoadInventory(userId)
end
end
function module.GetInventory(userId)
module.CreateInventory(userId)
return Inventory[userId]
end
function module.AddToInventory(userId, itemName)
module.CreateInventory(userId)
local inv = Inventory[userId]
for i = 1, maxSlots do
if not inv[i] then
inv[i] = itemName
return true
end
end
return false
end
function module.RemoveFromInventory(userId, slotIndex)
module.CreateInventory(userId)
if Inventory[userId][slotIndex] then
Inventory[userId][slotIndex] = nil
return true
end
return false
end
return module``` @formal vector
19:53:36.698 Infinite yield possible on 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler:WaitForChild("Reference")' - Studio
19:53:36.698 Stack Begin - Studio
19:53:36.698 Script 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler', Line 3 - Studio
19:53:36.698 Stack End - Studio
19:53:37.695 Infinite yield possible on 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler:WaitForChild("Reference")' - Studio
19:53:37.695 Stack Begin - Studio
19:53:37.695 Script 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler', Line 3 - Studio
19:53:37.695 Stack End - Studio
19:53:38.277 Infinite yield possible on 'Players.NexusBloxz:WaitForChild("isAttacking")' - Studio
19:53:38.277 Stack Begin - Studio
19:53:38.277 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.Ability1.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:53:38.277 Stack End - Studio
19:53:38.277 Infinite yield possible on 'Players.NexusBloxz:WaitForChild("isAttacking")' - Studio
19:53:38.277 Stack Begin - Studio
19:53:38.277 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.ClassAbility.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:53:38.278 Stack End - Studio
19:53:38.278 Infinite yield possible on 'Players.NexusBloxz:WaitForChild("isAttacking")' - Studio
19:53:38.278 Stack Begin - Studio
19:53:38.278 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.Ability3.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:53:38.278 Stack End - Studio``` @cosmic hollow
where is addtophysicalinventory tho?:
inventoryMod.AddToPhysicalInventory(player, Rapier)
ohh its dif script
tghis adds to module
disable warnings from output
ok
19:56:31.976 table 1 - Server - leaderstats:111
19:56:31.977 tempolate - Server - PhysicalInventoryModule:80
19:56:34.812 Stack Begin - Studio
19:56:34.812 Script 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler', Line 3 - Studio
19:56:34.812 Stack End - Studio
19:56:34.813 Stack Begin - Studio
19:56:34.813 Script 'cloud_9599081549.Moon VFX Exporter.Moon VFX Exporter.ExporterFramesHandler', Line 3 - Studio
19:56:34.813 Stack End - Studio
19:56:35.759 Stack Begin - Studio
19:56:35.759 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.Ability1.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:56:35.759 Stack End - Studio
19:56:35.759 Stack Begin - Studio
19:56:35.759 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.ClassAbility.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:56:35.759 Stack End - Studio
19:56:35.760 Stack Begin - Studio
19:56:35.760 Script 'Players.NexusBloxz.PlayerGui.Abilities.Frame.Ability3.Cooldown.Cooldown', Line 4 - Studio - Cooldown:4
19:56:35.760 Stack End - Studio```
@cosmic hollow
also is the datastore working
bc if it is then you are just gonna load the same thing over bc of your else statement
it should be since it printed table and 1 which is inside the success line
local DataStoreService = game:GetService("DataStoreService")
local DS = DataStoreService:GetDataStore("PlayerInventory")
local module = {}
local Inventory = {}
local maxSlots = 50
local function getKey(userId)
return "Inventory_" .. userId
end
function module.LoadInventory(userId)
local key = getKey(userId)
local success, data = pcall(function()-- data is the returned value
return DS:GetAsync(key)
end)
if success and type(data) == "table" then
Inventory[userId] = data
else
Inventory[userId] = {}
end
for i = 1, maxSlots do
Inventory[userId][i] = Inventory[userId][i]
end
end
function module.SaveInventory(userId)
local key = getKey(userId)
local data = Inventory[userId] or {}
pcall(function()
DS:SetAsync(key, data)
end)
end
function module.CreateInventory(userId)
if not Inventory[userId] then
module.LoadInventory(userId)
end
end
function module.GetInventory(userId)
module.CreateInventory(userId)
return Inventory[userId]
end
function module.AddToInventory(userId, itemName)
module.CreateInventory(userId)
local inv = Inventory[userId]
for i = 1, maxSlots do
if not inv[i] then
inv[i] = itemName
return true
end
end
return false
end
function module.RemoveFromInventory(userId, slotIndex)
module.CreateInventory(userId)
if Inventory[userId][slotIndex] then
Inventory[userId][slotIndex] = nil
return true
end
return false
end
return module``` @cosmic hollow
yes
so you're loading the same inventory over and over again then?
it loads level and all that
idk
how can i fix
try renaming the datastore to something different or renaming the keys rq
``` add this after the if and else statement
i wanna see what the inventory looks like
I think its running this top part every time
it is but i also think hes not adding anything to inventory
open the table in output
yeah and i think thats why bc its in the else part
how cann i fix
ok
that aswell but im pretty sure AddToPhysicalInventory doesnt exist
what is the name of this script
if success and worked and yes and ofcourse then
exp.Value = returned or 1
lvl.Value = ret or 1
money.Value = moneyRet or 0
-- NEW HEALTH LOGIC START --
local function updateMaxHealth(character)
local humanoid = character:WaitForChild("Humanoid")
-- Formula: Base 100 + (25 * Level)
local newMax = 100 + (lvl.Value * 25)
humanoid.MaxHealth = newMax
humanoid.Health = newMax -- Heals them to full on level up/spawn
end
print(typeof(inv), #inv)
** You are now Level 6! **
no no
you see the > {... }
when u see that in ur output
if u click on the ">"
it opens it
inventorymodld
send me what it shows
20:04:43.020 ▼ {
["Common"] = 50,
["Epic"] = 5,
["Legendary"] = 1,
["Rare"] = 10,
["Uncommon"] = 30
} - Server - leaderstats:36
@cosmic hollow
hmm
btqw
error
20:04:46.784 ServerScriptService.InGame.leaderstats:152: attempt to call a nil value - Server - leaderstats:152
no
bru
@cosmic hollow @formal vector
put a print here and test
20:13:03.520 hi - Server - leaderstats:129
yeah so thats kind of what i thought you see the problem?
right now you're only giving the wand if the player has nothing saved, but you already have the inventory with the rapier saved
yes
Change "Inventory" to some other name like "Inventory1" or something. This is making a fresh datastore.
did you test
is there anything in output
20:21:41.123 ServerScriptService.InGame.leaderstats:111: attempt to get length of a nil value - Server - leaderstats:111
its bc you did #inv and inv doesnt exist
no like inv is the inventory of the player retrieved from the datastore but on first playthrough there's nothing to retrieve
so it is setting inv to nil and you are checking nil
ye
bruh what
but inventorydatastore is like a collection of everybody's inventorys
ya
im so confused by your code
samwe
why does loadinventory take both userid and inv when in the code you sent later loadinventory is defined as only taking userid
its not even userid you're just giving the player
but like assuming all that works what im saying is some other player can join with nothing and you're going to have an error
bc the only reason it worked is the datastore was empty and now its not so if anyone tries to join it'll try to load their data and there wont be any
any new player*
idkk
to prove it you could start a 2 person server on studio, but I'm saying you should just change all of those conditions into one if inv then
no im actually supposed to be studying rn and this is frustrating and imma switch to unity soon anyways
nccc
bro doesnt even know what he cooked up 💯
wat