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
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Thank you!!
I didn't know you could this with a dummy, I thought it had to be a real player
Diedis an event of Humanoid not Player. So it should be good as long as the dummy has a humanoid.