I’m currently making a code redeeming system, and I’ve got everything working, but when I try to see if the user already has the item I want to give them, table.find is only able to detect said item table in the player’s inventory after they’ve redeemed the code once per session. Basically, a player can join a new game and it allows them to use the code once, and rejoining allows them to use it again.
I do know that the player does already have said item, because I’ve printed what they have before and after.
This screenshot shows the player’s inventory before they use the code, the first time they use the code, and the second time they use the code.
game.ReplicatedStorage.Events.redeemcode.OnServerEvent:Connect(function(player,code) local profile = getProfile(player) local codes = script.Codes local wpn = require(script.Weapons) if codes:GetAttribute(code) then if not table.find(profile.Data.Inventory.Weapons,wpn[codes:GetAttribute(code)]) then print(wpn[codes:GetAttribute(code)]) print(profile.Data.Inventory.Weapons) print("Could not find!") table.insert(profile.Data.Inventory.Weapons,wpn[codes:GetAttribute(code)]) end end end)
Any help is appreciated! Thanks!