Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gamepass not giving gui when player respawns? [ANSWERED]

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

✓ Accepted answer

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)

2 comments

0

Hmm.. Still not working... Any help? It only spawns once.

0

Works great! Thanks! :]

This discussion is preserved as it was. New answers, comments, and votes are closed.