script.Parent.MouseButton1Down:connect(function()
if game:GetService("GamePassService"):PlayerHasPass(game.Players.LocalPlayer, 167686361)
script.Parent.Parent.Frame.Visible = true
else
script.Parent.Parent.NoPass.Visible = true
wait(5)
script.Parent.Parent.NoPass.Visible = true
end
end)
Even though I have the gamepass, it skips down to the 'else'.

5 comments
I've added that in-game, I must of copied it wrong. But that still isn't working like it should.
The output in a normal server (in-game): Game passes can only be queried by a Script running on a ROBLOX game server
Is it in a local script or a server script?
If it is a local script, that would explain why it works when you play through the studio, but not through the server.
It's a local script, and I'm testing this in a normal game, by joining the place through the PLAY button.