would i have to do the same thing for
inventoryString.Value = HttpService:JSONEncode(inventoryData)
would i have to do the same thing for
inventoryString.Value = HttpService:JSONEncode(inventoryData)
Quick question. If you are not getting this data from an external server outside of roblox why are you encoding the data
To be honest i not sure, i watched someone use datastore2 and i realized a game i was going for used datastore2 so i wanted to use it so bad without knowing anything about it.
I watched this guy
Its ok so just use inventoryString.Value = decodedData
Where do i put that?
InventoryStore:OnUpdate(function(decodedData, player)
inventoryString.Value = HttpService:JSONEncode(decodedData) --Error here
end)
This part I think
check if the decoded data is nil using an if statement and if it is just use an empty string
would i do something like
if inventoryString.Value == decodedData then
print(decodedData)
if not decodedData then
decodedData = “”
end
inventoryString.Value = decodedData
now it just went blank
Thats because the string is empty
oh ok, and then what should i do?
That’s the problem fixed I believe. If you want to change what is says when it returns nil just edit the string
Wdym not save. Do you want it to save the inventory and have it load that data when they load into your game again
yes, thats what i have been looking for
What code do you have put that Gui in place
local replicatedstorage = game:GetService("ReplicatedStorage")
local armormodule = require(game.ReplicatedStorage:WaitForChild("ArmorHandler"))
local remote = replicatedstorage.Events:WaitForChild("UpdateInventory")
replicatedstorage.Events.UpdateInventory.OnClientEvent:Connect(function(player, armor)
local template = script.Parent.MainGui.InventoryHolder.Inventory.Templates.Template
local newTemplate = template:Clone()
newTemplate.Parent = script.Parent.MainGui.InventoryHolder.Inventory.Duplicates
local newArmor = armormodule.chooseRandom():Clone()
local camera = Instance.new("Camera")
local armorname = newArmor.Name
local template2 = script.Parent.MainGui.Reward.Template
local newTemplate2 = template2:Clone()
newTemplate2.Parent = script.Parent.MainGui.Reward
camera.CFrame = CFrame.new(newArmor.PrimaryPart.Position + (newArmor.PrimaryPart.CFrame.lookVector * 3), newArmor.PrimaryPart.Position)
camera.Parent = newTemplate2.ViewportFrame
newArmor.Parent = newTemplate2.ViewportFrame
newTemplate2.ViewportFrame.CurrentCamera = camera
script.Parent.MainGui.Reward.Visible = true
newTemplate2.Visible = true
wait(2)
script.Parent.MainGui.Reward.Visible = false
newTemplate2.Visible = false
newTemplate.Visible = true
camera.CFrame = CFrame.new(newArmor.PrimaryPart.Position + (newArmor.PrimaryPart.CFrame.lookVector * 3), newArmor.PrimaryPart.Position)
camera.Parent = newTemplate.ViewportFrame
newArmor.Parent = newTemplate.ViewportFrame
newTemplate.ViewportFrame.CurrentCamera = camera
end)
What you would do to make an inventory is set up all the inventory slots when the player first joins.
When you wanted to update it you would loop through the inventory data and match each item to a slot in the inventory. You would then get the item name and match it to a model then put that model in the viewport frame to render it
What you have rn seems to be the setup of one of those slots. That’s a good start but currently you are making a new slot every time the inventory is updated.