I am trying to make a game that has ending to it, in which one ending you can kill the enemy and a text box pops up on your screen and you get kicked. I just cant figure out why this wont work (I am pretty new to scripting)
local Zom = script.Parent:WaitForChild("Zombie")
Zom.Died.Connect(function()
print("test")
script.Parent.Touched:connect(function(hit)
game.Players.PlayerAdded:Connect(function(plr)
plr.PlayerGui.Black.Frame.Active = true
plr.PlayerGui.Black.Frame.BackgroundTransparency = .9
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = .8
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = .7
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = .6
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = .5
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = .4
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = .3
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = .2
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = .1
wait(.1)
plr.PlayerGui.Black.Frame.BackgroundTransparency = 0
wait(2)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .9
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .8
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .7
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .6
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .5
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .4
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .3
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .2
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = .1
wait(.1)
plr.PlayerGui.Black.Frame.TextLabel.TextTransparency = 0
wait(5)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player:Kick("Self Defence")
end) end) end)

2 comments
You are connecting events inside of events in other words they will be connected when the event runs. You should connect the events outide of each other.
Also you should be using loops / tweens for the gui fade