I scripted a gui to popup when you die and It doesn't popup when you're in the actual game but when you're in Studio, it works perfectly fine, please help me?
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:connect(function() script.Parent.DarkSoulsNoise:Play() script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.01) script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.01) script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.01) script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.01) script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.5) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(1.3) end)
Okay so what is happening is that the Character isn't loaded yet. You have this problem in the actual game due to scripts loading before your character does. In studio it is the opposite. So what you need to do is
local player = game.Players.LocalPlayer local char = Player.Character while char.Parent == nil do char.AncestryChanged:wait() end char:WaitForChild("Humanoid").Died:Connect(function() script.Parent.DarkSoulsNoise:Play() script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.01) script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.01) script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.01) script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.01) script.Parent.Deadline.BackgroundTransparency = script.Parent.Deadline.BackgroundTransparency - 0.2 wait(0.5) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(0.08) script.Parent.Deadline.YouAreDie.TextTransparency = script.Parent.Deadline.YouAreDie.TextTransparency - 0.1 wait(1.3) end)
This is because the scripts load in before the character is loaded. Just add this to your script. Also, switch to :Connect()
as ROLOX may be removing :connect()
soon.
Also instead of manually subtracting 0.2 from the transparency, use a for loop.
local plr = game:GetService'Players'.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() char.Humanoid.Died:Connect(function() for i = 1, 0, -.2 do script.Parent.Deadline.BackgroundTransparency = i wait() end for i = 1, 0, -.1 do script.Parent.Deadline.YouAreDie.TextTransparency = i wait() end end)