generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Checking for Game Pass (ERROR)

Previous Thread :: Next Thread 
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 04:58 AM
local passId = 1214124

function Clicked()
return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end
game.Players.PlayerAdded:connect(function(plr)
elseif Clicked() then
script.Parent.Parent.Frame.Visible = true
else script.Parent.Parent.NoPass.Visible = true
end)

script.Parent.MouseButton1Down:connect(Clicked)


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What's wrong with the above?

I'm trying to:
When a player clicks the imagebutton, it will check if he has a game pass, if he does, another GUI will pop up, but if he doesn't then a different GUI pops up (or one of those ROBLOX GUI's asking whether you want to purchase the game pass - if any one of you is able to make this work)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
22 Jul 2014 05:05 AM
"elseif" -> if*
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 05:09 AM
11:09:18.274 - Not a valid Player
11:09:18.275 - Script 'Players.Player1.PlayerGui.Guide.ImageButton.Script', Line 4
11:09:18.277 - Stack End
11:09:18.278 - Disconnected event because of exception
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Jul 2014 05:15 AM
player and passid not defined
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 05:26 AM
passId is defined

And how would I define the player in this case?
Report Abuse
magoo8 is not online. magoo8
Joined: 25 Apr 2009
Total Posts: 1122
22 Jul 2014 05:29 AM
local id = IDHERE

game.Players.PlayerAdded:connect(function(plr)
if game:GetService("GamepassService"):PlayerHasPass(plr, id) then
script.Parent.Visible = true
end)
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 05:33 AM
? I'm totally lost.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
22 Jul 2014 05:33 AM
...
Didn't look at the actual script.
What is this even in?
This would be a local script inside of a gui.
Why are you using the PlayerAdded event inside of something that will replicate to all users?
Define the player in the local script and remove anonymous function and it's innards.
player = game.Players.LocalPlayer
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 05:36 AM
Should it look like this?


local passId = 167686361
local player = game.Players.LocalPlayer

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

if Clicked() then
script.Parent.Parent.Frame.Visible = true
else script.Parent.Parent.NoPass.Visible = true
end
end)

script.Parent.MouseButton1Down:connect(Clicked)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
22 Jul 2014 05:38 AM
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
end
end)
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 05:38 AM
I'm still getting "Not a valid player - line 5" in the output :/
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 05:40 AM
Testing your script...
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 05:41 AM
if game:GetService("GamePassService"):PlayerHasPass(game.Players.LocalPlayer, 167686361) then


~~~~~~~~~~~~~

-- not a valid player.
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 05:43 AM
It goes down to 'else' even though I have the pass...
Report Abuse
cokePanda is not online. cokePanda
Joined: 30 Dec 2008
Total Posts: 1901
22 Jul 2014 06:20 AM
bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image