I have a zombie game which shows the backpack when gameInProgress is true and removes it when it is false. However, if players die and there are other players who are still alive; gameInProgress will still be true. I am trying to disable weapons in the lobby by disabling the CoreGUI Backpack when the player dies, if anyone could help me, that’d be really great!
Try using the Humanoid.Died event here is an example
local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
repeat wait() until humanoid
humanoid.Died:Connect(function()
game:GetService("StarterGui"):SetCoreGuiEnabled("Backpack", false)
end)
Now I don’t know if you want the player to have his backpack enabled again when he respawns.
This is nice, but to answer what you said at the end; No I do not want the backpack to be enabled again when the player respawns.
You could add some bool value in the player that would be if they died then the code that Ubicast posted activates the bool is set to true and then have some script check if that bool was true and if it was disable the gui or something
This doesn’t seem to work, i’ve made it a local script in StarterPlayerScripts and it didn’t work.
Try putting this LocalScript
in StarterCharacterScripts
:
local humanoid = script.Parent:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end)