Greetings!
I seem to never escape Lua's many confusions, as it's still a steep learning curve for me (but I still hope to really learn it thoroughly and create some great games with my friend), but something new's creeped up on me.
Recently, we had some contributors help with models for this game, and my friend instructed me to script it so that they can access a VIP GUI without having to purchase the pass, as a thank you to them.
So, me, thinking that it's simple, write this (as an example):
local player = game.Players.LocalPlayer local vipframe = script.Parent.Parent.VIPFrame function onClick() if player.Name == "Jeff" or player.Name == "Bob" or player.Name == "Jeb" then print('Player is on list.') vipframe.Visible = true end if game.Workspace.VIPGamepass:InvokeServer(12345678) then print('Player has pass.') vipframe.Visible = true else print('Player doesn't have game pass.') game:GetService("MarketplaceService"):PromptPurchase(player,12345678) end end
The button works if say my name is on the list, as in the console it shows 'Player is on list', however when I remove my name to check for the pass... nothing. It doesn't invoke and check if I have the pass, nor displays the VIP GUI, nor prompt me to purchase. I am quite confused, and I have a suspicion that it has to do with my use of if statements, but I am otherwise lost. Any clues?
Try this, I used a different ROBLOX function to check if they own the pass.
local player = game.Players.LocalPlayer local vipframe = script.Parent.Parent.VIPFrame function onClick() if player.Name == "Jeff" or player.Name == "Bob" or player.Name == "Jeb" then print('Player is on list.') vipframe.Visible = true end if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userid,12345678) then print('Player has pass.') vipframe.Visible = true else print("Player doesn't have game pass.") game:GetService("MarketplaceService"):PromptPurchase(player,12345678) end end