no both codes are certainly running but the death screen just doesn’t appear. it appears if i fall in the void or set my health to 0 via humanoid in workspace.
you just said “and the line does kill the player but the player doesn’t die”
before that you said “I have a death screen for when you die and it works, but when you get killed by the monster, it doesn’t work.”
“it works but it doesn’t work”
you’re not telling us anything in fear of us stealing your terribly written code.
(the part where I help:)
“script.Parent.Parnt” Parnt is a typo
so if you don’t see any errors than your Humanoid.Died event is not firing because most likely the script isn’t running (localscript can only execute in specific directories like PlayerGui, PlayerScripts, CharacterScripts, ReplicatedFirst, Etc)
make sure your script is running by adding
print("UI Script Loaded Successfully")
to the end of your script to make sure it gets there
No i just didn’t give the rest of the code because it’s pretty irrelevant. Plus the code worked somehow with the typo. I fixed it but it still doesn’t appear when the monster kills the player. If you die by other means it does appear.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local ScriptOrUIContainerCantTellTheyJustGetDestroyed = script.Parent.Parent.Parent
local redscreen = script.Parent.Parent.RedScreen
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(10,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out)
local ti2 = TweenInfo.new(2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out
)
local FinishTweens = {}
local tg = {BackgroundColor3 = Color3.fromRGB(0, 0, 0)}
local tg2 = {TextTransparency = 0}
local tc = ts:Create(redscreen, ti, tg)
local ButtonList = {"MenuButton","RestartButton","DeathText","RestartChButton"}
for _,ButtonName in pairs (ButtonList) do
local Button = script.Parent:FindFirstChild("Button")
if Button then
table.insert(FinishTweens,ts:Create(Button, ti2, tg2))
end
end
Humanoid.Died:Connect(function()
print("Humanoid died! OH NO!!!")
ScriptOrUIContainerCantTellTheyJustGetDestroyed.RunningScript:Destroy()
game:GetService("UserInputService").ModalEnabled = true
ScriptOrUIContainerCantTellTheyJustGetDestroyed.GamePaused:Destroy()
redscreen.Visible = true
tc:Play()
tc.Completed:Connect(function()
redscreen.Visible = false
script.Parent.Visible = true
for _,Tween in pairs (FinishTweens) do
Tween:Play()
end
print("Death screen appeared")
end)
end)
test this. if it doesn’t print (“Humanoid Died! OH NO!!!”) then something is seriously wrong somewhere
also shortened code to reduce the use of redundant values that are just copies of other values