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

Why does the Spawn GUI still appear even if people don't own the gamepass?

Asked by 10 years ago

I have this script in a GUI that detects if a player owns a Gamepass, it then deletes the script. However, every time someone joins, some appear as Spawn, yet they don't own the gamepass! Anyone see an issue with the script?

01passid = 158752762
02 
03local GamePassService = game:GetService("GamePassService")
04function respawned(char)
05local player = game.Players:FindFirstChild(char.Name)
06 
07if char:FindFirstChild("Head") ~= nil then
08wait (0.01)
09if GamePassService:PlayerHasPass(player, passid) then
10script.Parent.Parent.Spawn.Visible = true
11wait()
12script.Parent:remove()
13else
14 
15end
16end
17end
18game.Workspace.ChildAdded:connect(respawned)

Cheers in advanced,

Michael

1 answer

Log in to vote
2
Answered by
iNicklas 215 Moderation Voter
10 years ago
01passid = 158752762
02 
03local GamePassService = game:GetService("GamePassService")
04function respawned(char)
05local player = game.Players:FindFirstChild(char.Name)
06 
07if GamePassService:PlayerHasPass(player, passid) then
08script.Parent.Parent.Spawn.Visible = true
09else
10script.Parent:remove()
11wait(.01)
12end
13end
14game.Workspace.ChildAdded:connect(respawned)

script.Parent:remove() was located wrong, it is supposed to be after else, so if they dont have the passid it gets removed.

0
You don't need a wait() in the script, it's quite unnecessary. Also, you don't always need a number in between the parenthesis of wait(). Spongocardo 1991 — 10y
0
its quite an annoying habit of mine :/. I have a habit of typing local text constantly. iNicklas 215 — 10y
0
Thanks again iNicklas! BTW, weren't you the one that gave me this script like 2 days ago?!?! xD Michael007800 144 — 10y
0
tru that xd, but i did put script.Parent the right place :P iNicklas 215 — 10y
Ad

Answer this question