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

fix to this gamepass death script? [UNSOLVED]

Asked by
Bman8765 270 Moderation Voter
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)
0
Did not work Bman8765 270 — 9y
0
Are you trying this online or with Play Solo? UndefinedVariable 10 — 9y
0
Online Bman8765 270 — 9y
0
I'm not sure then, my apologies. UndefinedVariable 10 — 9y
Ad

Answer this question