Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Textbutton script does not work?

Asked by 10 years ago

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

0
where is the error TochiWasHere 10 — 10y
0
The dev console says nothing, but the script will not work PyccknnXakep 1225 — 10y
0
Hmm... HexC3D 830 — 10y
0
Can somebody please fix my script? PyccknnXakep 1225 — 10y
View all comments (2 more)
0
I'll try HexC3D 830 — 10y
0
Thx PyccknnXakep 1225 — 10y

1 answer

Log in to vote
1
Answered by
HexC3D 830 Moderation Voter
10 years ago

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
0
thanks PyccknnXakep 1225 — 10y
Ad

Answer this question