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

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

Asked by 9 years ago

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!

0
is this in a Localscript? woodengop 1134 — 9y
0
Yes Michael007800 144 — 9y
0
Playeradded doesn't work with a localscript, do use the childadded function or localplayer. woodengop 1134 — 9y
0
And if I made this a normal script? Michael007800 144 — 9y
View all comments (3 more)
0
try it. woodengop 1134 — 9y
0
Didn't work! D: Michael007800 144 — 9y
0
Is that a free model?... :p lucas4114 607 — 9y

1 answer

Log in to vote
0
Answered by
iNicklas 215 Moderation Voter
9 years ago
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)




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? woodengop 1134 — 9y
1
I visited his game, and explained it to him. And he thanked me. But thank you for -1. iNicklas 215 — 9y
0
Yeah, I forgot to define the character! xD Michael007800 144 — 9y
Ad

Answer this question