|
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) |
|
|
|
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 |
|
|
player and passid not defined |
|
|
passId is defined
And how would I define the player in this case? |
|
ByDefaultJoin Date: 2014-07-25 Post Count: 4022 |
local id = IDHERE
game.Players.PlayerAdded:connect(function(plr)
if game:GetService("GamepassService"):PlayerHasPass(plr, id) then
script.Parent.Visible = true
end) |
|
|
|
...
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 |
|
|
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) |
|
|
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) |
|
|
I'm still getting "Not a valid player - line 5" in the output :/ |
|
|
|
if game:GetService("GamePassService"):PlayerHasPass(game.Players.LocalPlayer, 167686361) then
~~~~~~~~~~~~~
-- not a valid player. |
|
|
It goes down to 'else' even though I have the pass... |
|
|