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

My gamepass script doesn't work, but it's so basic. Why?

Asked by 4 years ago

I have a gamepass called Collection of Coils. It basically gives the player who ones the gamepass a Regeneration Coil, a Gravity Coil, and a Speed Coil. I have the tools in a folder inside ReplicatedStorage. The folder is called Tools. I used :UserOwnsGamePassAsync().

Here is my script:

local marketplace = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
    if marketplace:UserOwnsGamePassAsync(player.UserId,6565908) then
        local items = game.ReplicatedStorage:FindFirstChild("Items")
        if items then
            for _,v in pairs(items:GetChildren()) do
                v:Clone().Parent = player:WaitForChild("Backpack")
                v:Clone().Parent = player:WaitForChild("StarterGear")
            end
        end
    end
end)

Any help is appreciated. You can use a different gamepass ID. You don't need to buy mine :P

0
Are there any errors? If not, can you check if you used the right Gamepass Id? Mr_Unlucky 1085 — 4y

1 answer

Log in to vote
2
Answered by
Prestory 1395 Moderation Voter
4 years ago
Edited 4 years ago

Try this i think the problem is that you said the folder was called "Tools" but in your code it searches ReplicatedStorage for "Items"

local MarketPlaceService = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    if MarketPlaceService:UserOwnsGamePassAsync(player.UserId,6565908) then
    local Items = game:GetService('ReplicatedStorage'):WaitForChild("Tools")
        if Items then
            for _,v in pairs(Items:GetChildren()) do
            v:Clone().Parent = player:WaitForChild("Backpack")
            v:Clone().Parent = player:WaitForChild("StarterGear")
            end
        end
    end
end)
0
To be fair there might be a chance in which he just named the variable Items on accident and there is an actual folder/model called Tools. But this can be possible Mr_Unlucky 1085 — 4y
0
Yea i know but im just taking into account what he said and acting on it because when i tested this script in studio it worked perfectly for me which lead me to only one conclusion Prestory 1395 — 4y
Ad

Answer this question