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

fix to this gamepass death script? [UNSOLVED]

Basically this is a script in workspace so when a player dies if they have the gamepass a gui will show up after waiting 10 seconds. The code is below but it is not working, any help?

----------------------------------------------------------------------------------------------------
print("OnPlayerDeath script loading variables")
----------------------------------------------------------------------------------------------------
--Insert VARIABLES Below
----------------------------------------------------------------------------------------------------
local GamePassService = game:GetService("GamePassService")
local GamePassId = 185260715
----------------------------------------------------------------------------------------------------
print("OnPlayerDeath script working")
----------------------------------------------------------------------------------------------------

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			print("Someone Died")
			if GamePassService:PlayerHasPass(player, GamePassId) then
				wait(5)
				print("They have game pass")
				player.PlayerGui.MenuGUI.Menu.twoDoff.Visible = true
			end
		end)
	end)
end)

1 answer

I'm not entirely sure, but I think you can't do "character:WaitForChild("Humanoid").Died:connect(function()"

and, the character may respawn before the wait(5) is finished.

This may help:

----------------------------------------------------------------------------------------------------
print("OnPlayerDeath script loading variables")
----------------------------------------------------------------------------------------------------
--Insert VARIABLES Below
----------------------------------------------------------------------------------------------------
local GamePassService = game:GetService("GamePassService")
local GamePassId = 185260715
----------------------------------------------------------------------------------------------------
print("OnPlayerDeath script working")
----------------------------------------------------------------------------------------------------

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
	local humanoid = character:WaitForChild("Humanoid")
        humanoid.Died:connect(function()
            print("Someone Died")
            if GamePassService:PlayerHasPass(player, GamePassId) then
                wait(.25)
                print("They have game pass")
                player.PlayerGui.MenuGUI.Menu.twoDoff.Visible = true
            end
        end)
    end)
end)

4 comments

0

Did not work

0

Are you trying this online or with Play Solo?

0

Online

0

I'm not sure then, my apologies.

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