Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Textbutton script does not work?

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

6 comments

0

where is the error

0

The dev console says nothing, but the script will not work

0

Hmm...

0

Can somebody please fix my script?

0

I'll try

0

Thx

1 answer

✓ Accepted answer

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



1 comment

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.