Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

Are there any errors? If not, can you check if you used the right Gamepass Id?

1 answer

✓ Accepted answer

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)

2 comments

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.