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
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'.

2 answers

Log in to vote
1
Answered by 10 years ago

Got it working:

local player = script.Parent.Parent.Parent.Parent
local noPass = script.Parent.Parent.NoPass
local gui = script.Parent.Parent.Frame

script.Parent.MouseButton1Down:connect(function()
    if game:GetService("GamePassService"):PlayerHasPass(player, 167686361) then
    gui.Visible = true
        else
        noPass.Visible = true
        wait(5)
        noPass.Visible = false
    end
end)
Ad
Log in to vote
0
Answered by
Necrorave 560 Moderation Voter
10 years ago
script.Parent.MouseButton1Down:connect(function()
    if game:GetService("GamePassService"):PlayerHasPass(game.Players.LocalPlayer, 167686361) then -- You forgot to add "then"
    script.Parent.Parent.Frame.Visible = true
        else
        script.Parent.Parent.NoPass.Visible = true
        wait(5)
        script.Parent.Parent.NoPass.Visible = true
    end
end)

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