New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

Why is this game pass script not working?

Asked by 4 years ago

This game pass script is not working, and I have no idea why. It is supposed to give a player that owns the game pass a weapon.

Can someone please help me?

Here's the script:

local passId = 320562253

function authenticate(player) 
return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end


function Enter(plr)
wait(0.5)
if authenticate(plr) then
local c = plr.M1014
c.Value = true
end
end
game.Players.ChildAdded:connect(Enter) 

1 answer

Log in to vote
1
Answered by
GShocked 148
4 years ago

I believe authenticate(player) returns a bool value (meaning true or false). So your if statement basically checks if the returned value of authenticate(palyer) is not nil, not if it is true or false. So here should be the fixed code:

local passId = 320562253

function authenticate(player) 
return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end


function Enter(plr)
wait(0.5)
if authenticate(plr) == true then
local c = plr.M1014
c.Value = true
end
end
game.Players.ChildAdded:connect(Enter) 
0
It works, thanks! CoolJohnnyboy 121 — 4y
Ad

Answer this question