When I kill the NPC, nothing happens. Thoughts? Very new to scripting
while true do if workspace.Dummy.Humanoid.Health <1 then workspace.Cam.Union.Transparency = 1 end end
One thing that might be the problem is that the script is checking to fast. The script can get tired if it is checking the health way to fast. A cleaner meathod is a built-in event called changed, if the health is changed, then the event will fire. Inside the changed event you can check the health.
local health = workspace.Dummy.Humanoid.Health health.Changed:Connect(function() -- Everything below will run when the health changes if health == 0 then workspace.Cam.Union.Transparency = 1 end end)
I hope this works!
You can use the Died
event of Humanoid
which only fires when the humanoid dies. Instead of constantly checking for it's health which is extremely inefficient.
workspace.Dummy.Humanoid.Died:Connect(function() workspace.Cam.Union.Transparency = 1 end)