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

Why is this Gamepass Script not Working?

Asked by 9 years ago

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.

0
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(: Goulstem 8144 — 9y
0
If I am correct, game passes only work in online, so I cannot tell you the output. CoolJohnnyboy 121 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Tell me what output window tells you. And by the way writing code in localscripts sometimes works better than regular script.

Ad

Answer this question