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

Why is this goin down to 'else' and skips 'if'? (FIXED IT)

Asked by 10 years ago
1script.Parent.MouseButton1Down:connect(function()
2    if game:GetService("GamePassService"):PlayerHasPass(game.Players.LocalPlayer, 167686361)
3    script.Parent.Parent.Frame.Visible = true
4        else
5        script.Parent.Parent.NoPass.Visible = true
6        wait(5)
7        script.Parent.Parent.NoPass.Visible = true
8    end
9end)

Even though I have the gamepass, it skips down to the 'else'.

2 answers

Log in to vote
1
Answered by 10 years ago

Got it working:

01local player = script.Parent.Parent.Parent.Parent
02local noPass = script.Parent.Parent.NoPass
03local gui = script.Parent.Parent.Frame
04 
05script.Parent.MouseButton1Down:connect(function()
06    if game:GetService("GamePassService"):PlayerHasPass(player, 167686361) then
07    gui.Visible = true
08        else
09        noPass.Visible = true
10        wait(5)
11        noPass.Visible = false
12    end
13end)
Ad
Log in to vote
0
Answered by
Necrorave 560 Moderation Voter
10 years ago
1script.Parent.MouseButton1Down:connect(function()
2    if game:GetService("GamePassService"):PlayerHasPass(game.Players.LocalPlayer, 167686361) then -- You forgot to add "then"
3    script.Parent.Parent.Frame.Visible = true
4        else
5        script.Parent.Parent.NoPass.Visible = true
6        wait(5)
7        script.Parent.Parent.NoPass.Visible = true
8    end
9end)

You forgot the "then" after the if condition. If you come across another issue, then we may need to take a harder look. This is just what I noticed at first glance.

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

Answer this question