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

Gamepass not giving gui when player respawns? [ANSWERED]

Asked by 9 years ago

Hello scripting helpers,

I've just come across an error.

Below this, I have made a GUI cloner when a player spawns or de-spawns.

It checks if the player has a gamepass and if so, clones the gui into the players gui.

I used this on the 4th line:-

game.Players.ChildAdded:connect(function(player)

It only cloned the GUI when a player entered a game and not when she/he respawned.

Here is the full script:-

local clone = game.ServerStorage.ttt:Clone()
local id = 213876340

game.Players.ChildAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then
        print "Player has gamepass"
        clone.Parent = player.PlayerGui
    else
        print "Player doesn't have gamepasss"
    end
end)

Any help? Nathan. :]

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Very simply, you need to use the CharacterAdded Event:

local clone = game.ServerStorage.ttt
local id = 213876340

game.Players.ChildAdded:connect(function(player)
    player.CharacterAdded:connect(function()
        if game:GetService("GamePassService"):PlayerHasPass(player, id) then
            print "Player has gamepass"
            clone:Clone().Parent = player.PlayerGui --You also need to make a clone of the Clone here.
        else
            print "Player doesn't have gamepasss"
        end
    end)
end)
0
Hmm.. Still not working... Any help? It only spawns once. WelpNathan 307 — 9y
0
Works great! Thanks! :] WelpNathan 307 — 9y
Ad

Answer this question