I want to make it so my deathGui doesnt show up when you score. How? (check bottom for more info)
this script checks if a player is on red team when they touch a block then if that person is, the person gets one point. Then once that happens it makes a frame show up and kills all players. But I have a Gui that pops up when you die, I would like to make it so when it kills you after you score. The DeathGui doesnt show up.
i tried to do that with this : player:WaitForChild("PlayerGui"):WaitForChild("DeathGui").Enabled = not visible. But it does not work, Can anybody tell me why this is happening thank you. (By the way the code is on line 20)
01 | local Players = game:GetService( "Players" ) |
02 | local Teams = game:GetService( "Teams" ) |
04 | local function killEveryPlayer() |
05 | for _, player in ipairs (Players:GetPlayers()) do |
07 | local character = player.Character |
08 | if ( not character) or ( not character.Parent) then |
09 | character = player.CharacterAdded:Wait() |
11 | character:FindFirstChildOfClass( "Humanoid" ).Health = 0 |
16 | local function redTeamScoredFrame(visible: boolean) |
17 | for _, player in ipairs (Players:GetPlayers()) do |
19 | player:WaitForChild( "PlayerGui" ):WaitForChild( "RedTeamScored" ):WaitForChild( "Frame" ).Visible = visible |
20 | player:WaitForChild( "PlayerGui" ):WaitForChild( "DeathGui" ).Enabled = not visible |
26 | script.Parent.Touched:Connect( function (hit) |
27 | local player = Players:GetPlayerFromCharacter(hit:FindFirstAncestorOfClass( "Model" )) |
28 | if (player and player.Team.Name = = "Red Team" ) and (debounce = = false ) then |
30 | player.leaderstats.Points.Value + = 1 |
32 | task.spawn(killEveryPlayer) |
33 | task.spawn(redTeamScoredFrame, true ) |
36 | task.spawn(redTeamScoredFrame, false ) |