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)
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)