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 9 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?

passid = 158752762

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.Parent.Spawn.Visible = true
wait()
script.Parent:remove()
else

end
end
end
game.Workspace.ChildAdded:connect(respawned)

Cheers in advanced,

Michael

1 answer

Log in to vote
2
Answered by
iNicklas 215 Moderation Voter
9 years ago
passid = 158752762

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

if GamePassService:PlayerHasPass(player, passid) then
script.Parent.Parent.Spawn.Visible = true
else
script.Parent:remove()
wait(.01)
end
end
game.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 — 9y
0
its quite an annoying habit of mine :/. I have a habit of typing local text constantly. iNicklas 215 — 9y
0
Thanks again iNicklas! BTW, weren't you the one that gave me this script like 2 days ago?!?! xD Michael007800 144 — 9y
0
tru that xd, but i did put script.Parent the right place :P iNicklas 215 — 9y
Ad

Answer this question