Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my for loop not detect my first gamepass item?

Asked by 3 years ago

I am using a gamepass manager to give players items and I use a module script to store the item names and IDs so it is easier for me to add and remove items. However whenever I try and get the first item on the list the server script does not even know that it is there as proven by me using print to bug test. However it detects the other ones in a for loop. It also produces no regular errors in output.

Server script

local Guns = game.ServerStorage.Pass
local Ids = require(script.Ids)
local MPS = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if char.Humanoid.Health == 100 then
            for i = 1, #Ids do
                if MPS:UserOwnsGamePassAsync(plr.userId, Ids[i].PassId) then
                    for _, item in pairs(Guns:GetChildren()) do
                        if Ids[i].name == item.Name then
                            print(Ids)
                            local e = item:Clone()
                            e.Parent = plr.Backpack
                        end 
                    end
                else
                    print("No")
                end
            end
        end
    end)
end)

Module Script



local GamepassIds = { { name = "Z-6"; PassId = 10257047; }; { name = "Squad Shield"; PassId = 10257050; }; { name = "Mandalorian Westar"; PassId = 10257070; }; { name = "DC-17"; PassId = 10258171; }; { name = "DC-15A"; PassId = 10280058; }; { name = "DC-17M"; PassId = 11246205; }; } return GamepassIds
0
I tested it myself both inside of ROBLOX and in the stock Lua language, they both have successfully iterated over all six packets; I suggest you restart ROBLOX Studio. Ziffixture 6913 — 3y
0
I restarted it. put it in another world and it still only detects 5, is there anything that I can do with my studio to fix this because I am stumped ExecutiveJoe 5 — 3y

Answer this question