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

How would I get a GUI Frame to delete if a player owns a Gamepass?

I am wondering how I would get this to work. The script will delete a BUY NOW button if the user already owns the Gamepass connected to it.

local passid = 162695807 -- The ID of the gamepass goes here
local tools = {"Duck Bike"} -- Here you just put the name(s) of the tool(s) you want given. (Tools must be put in the lighting)
local GamePassService = Game:GetService('GamePassService')
game.Players.PlayerAdded:connect(function(player)
if GamePassService:PlayerHasPass(player, passid) then
script.Parent:remove()
end
end)

This is what I have so far, but the chances of it working are very, very slim!

7 comments

0

is this in a Localscript?

0

Yes

0

Playeradded doesn't work with a localscript, do use the childadded function or localplayer.

0

And if I made this a normal script?

0

try it.

0

Didn't work! D:

0

Is that a free model?... :p

1 answer

✓ Accepted answer
passid = 162695807
tools = {"Duck Bike"}

local GamePassService = game:GetService("GamePassService")
function respawned(char)
local player = game.Players:FindFirstChild(char.Name)

if char:FindFirstChild("Head") ~= nil then
wait (0.01)
if GamePassService:PlayerHasPass(player, passid) then
script.Parent:remove()
else
	
end
end
end
game.Workspace.ChildAdded:connect(respawned)




3 comments

1

You shouldn't give out code just like that, You should Explain what you added, Is it in a LocalScript or a Script? What is ChildAdded(in case the user doesn't understand it), Why are you checking if the head exists?

1

I visited his game, and explained it to him. And he thanked me. But thank you for -1.

0

Yeah, I forgot to define the character! xD

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