Soo, i made a gamepass that is supposed to give you a balloon. I found help and ended up with the script below. The problem is when i join the game. i own the gamepass, but don’t receive the balloon. It works perfectly fine in a studio testing thing though. I looked at some other posts, but nothing worked.
heres the script:
local plrs = game:GetService("Players")
local mps = game:GetService('MarketplaceService')
local serverSorage = game:GetService("ServerStorage")
local tools = serverSorage.GamepassTools
local gamepassTools = {
{Name = "Balloon", ID = 685694181},
}
plrs.PlayerAdded:Connect(function(plr)
for _,v in gamepassTools do
local hasPass = false
local success, msg = pcall(function()
hasPass = mps:UserOwnsGamePassAsync(plr.UserId, v.ID)
end)
if hasPass then
local tool = tools[v.Name]:Clone()
tool.Parent = plr.Backpack
else
print("not owned")
end
if not success then
warn(msg)
end
end
end)
(i made it into a table because i plan on adding more)
I did publish it, plus i checked and everything i added right before and after i made this gamepass do work.
In studio, there are no errors in the output or anything else that could be bad. in game when i press f9, its the same thing. the ‘not owned’ thing never shows up
If you add a bunch more print statements throughout the script (at the start of the script; within the PlayerAdded etc.), up until where does the script function correctly.
soo it seems like the problem must be the cloning and giving of the tool, not the rest. This is what outputs ingame.
both “Balloon” and the players name print after the tool gets parented to the players backpack, so the issue couldn’t be with the player actual checking for gamepass thing, right?
it also would mean that it is getting the right tool which i wondered if that was it.
updated script if you want to see where i put prints:
plrs.PlayerAdded:Connect(function(plr)
for _,v in gamepassTools do
local hasPass = false
local success, msg = pcall(function()
hasPass = mps:UserOwnsGamePassAsync(plr.UserId, v.ID)
print("checking for pass")
end)
print("player added")
if hasPass then
local tool = tools[v.Name]:Clone()
tool.Parent = plr.Backpack
print(tool)
print(plr)
else
print("not owned")
end
if not success then
warn(msg)
end
end
end)
Definitely seems to be with the cloning for some reason.
If you put the tool into the default backpack thing in studio ( I can’t remember what the place is called, StarterPack?), does the tool get deleted or anything? Test it in studio and in game (You’ll revert this later as this is just to check something)
alr so i just went ahead n got rid of the table and used a straight variable to the tool, and it worked. i must have wrote something wrong but this will work overall.