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

GUI not visible when player owns Gamepass. Why?

Asked by 9 years ago

Hey guys,

I've been wondering what I am missing in this script!

BadgeId = 160235804

game.Players.PlayerAdded:connect(function(p)
if game:GetService("BadgeService"):UserHasBadge(p.userId, BadgeId) then
script.Parent.Parent.Spawn.Visible = true
script.Parent.Parent.Parent.OwnedBikes.Bike2.Visible = true
else
script.Parent:remove()
wait(.01)
    end
end)

game.Workspace.ChildAdded:connect(respawned)

I don't see a problem with it but it should have worked. If anyone sees a problem I've overlooked, please say!

Cheers,

Michael

1 answer

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Well, if you want it to be for a Gamepass, you need to use the PlayerHasPass method of the GamePassService. I see that you wanted it every time they respawn, but you didn't make a function named "respawned" to connect! The 'remove()' method is deprecated, so use :Destroy(). Here's your script fixed up:

BadgeId = 160235804
game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function(char)
        if game:GetService("GamePassService"):PlayerHasPass(p, BadgeId) then
            script.Parent.Parent.Spawn.Visible = true
            script.Parent.Parent.Parent.OwnedBikes.Bike2.Visible = true
        else
            script.Parent:Destroy()
        end
    end)
end)

0
*badge! My fault! I want it a badgr, not a gamepass! xD Michael007800 144 — 9y
Ad

Answer this question