So this game pass script is supposed to make a value in the player that has the game pass true, and then give them a bullet proof vest. However, the script is not working, and I have no idea why.
Can someone please help me?
Here's the script that makes the value true if the player has the gamepass
gps = game:GetService("GamePassService");
id = script:WaitForChild("GamePassID");
game.Players.PlayerAdded:connect(function(Player)
Player:WaitForDataReady()
if gps:PlayerHasPass(Player , id.Value) then
local BP = Player:WaitForChild("BPV")
if BP~=nil then
BP.Value = true
end
end
end)
And here's the script that gives the features, the bullet proof vest
local Player = script.Parent
local Char = Player:WaitForChild("Character")
local Value = Player:WaitForChild("BPV")
while wait() do
if Value ~= nil then
if Value == true then
local Checky = Char:WaitForChild("VestI")
if Checky.Value == false then
local g = game.ServerStorage.Vest:clone()
g.Parent = Char
local C = g:GetChildren()
Checky.Value = true
for i=1, #C do
if C[i].className == "Part" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = Char.Torso
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
end
end
As far as I know, everything is defined.

2 comments
Any errors in the output? Also I advise using the 'PlayerOwnsAsset' function, rather than 'PlayerHasPass'. It returns live results from the website meaning if a player buys the gamepass while still in your game then they won't have to rejoin for it to activate(:
If I am correct, game passes only work in online, so I cannot tell you the output.