This script is supposed to detect if the player has the gamepass. If the player doesnt, the player can buy the pass. if the player does have it, the button says purchased instead of buy and the player cant buy the pass.
--This goes in a textbutton called 'BuyButton' gpid = 160540391 --Gamepass ID GPS = Game:GetService("GamePassService") function respawned(char) player = game.Players:FindFirstChild(char.Name) print("Respawned") if char:FindFirstChild("Head") ~= nil then print("It's a Player!") if GPS:PlayerHasPass(player, gpid) then script.Parent.Text = "Purchased" --The textbutton text says purchased instead of buy script.Parent.BuyButton.LocalScript = remove() --removes the local script that registers the purchase end end end
Please note this script is going in several textbuttons. Please help. The script isnt working. I'm a little noobish at gui's so...
Let's say this the order of GUI(For the script to work in my example)
SCREEN GUI
FRAME
(BuyButton)TextButton(The script is in TextButton)
gpid = 160540391 GPS = game:GetService("GamePassService") player = script.Parent.Parent.Parent.Parent print("Respawned") if player.Character:FindFirstChild("Head") ~= nil then print("It's a Player!") end if GPS:PlayerHasPass(player, gpid) then script.Parent.Text = "Purchased" --The textbutton text says purchased instead of buy script.Parent.LocalScript:Destroy() -- Try Destroy since remove() is deprecated and you wrote it out wrong, also since this in BuyButton end