How to make if npc health = 0, then gui visible = true npc = game.Workspace.NPC gui = game.StarterGui.ScreenGui.Frame -Thank you and best regards
You would write it how you explained it, except switch the variables to the top otherwise we won't know what the NPC. And it is better to access playerGui rather than StarterGui
Here is your script:
if npc.Health = 0 then gui.Visible = true end npc = game.Workspace.NPC gui = game.StarterGui.Screengui.Frame
Revised script:
local npc = game.Workspace.NPC -- better to use local the whole time unless you need to use global local gui = player.PlayerGui.Screengui.Frame --[[ better to locate the playergui, or put this script in the gui and classify upwards local gui = script.Parent.Parent.Frame]] local humanoid = npc:WaitForChild("Humanoid") -- humanoid can access health, not the model NPC humanoid.Died:Connect(function() -- Died event is better than an if statement wait(0.5) -- you can remove this :) gui.Visible = true end)
Here are some links if you're confused about my comments: Variables PlayerGui Humanoid.Died Event