01 | local h = script.Parent.Humanoid |
02 |
03 | while true do |
04 | h:MoveTo(workspace.DontClean 1. Position) |
05 | wait( 5 ) |
06 | h:MoveTo(workspace.DontClean 2. Position) |
07 | wait( 5 ) |
08 | end |
09 |
10 | if h.Health then |
11 | if h.Health = = 0 then |
12 | game.Lighting.SuperEvilKeycard:Clone().Parent = game.Players.LocalPlayer.Backpack |
13 | script.Parent:Destroy() |
14 | end |
15 | end |
The humanoid moves, but when it dies, nothing happens. There isn't any output errors, i dont know what's happening. as always, i would be happy to elaborate
As the post above me said, you've got a loop that won't let your script continue. Therefore, you're going to need to force the script to run two things at once. Scary, I know. This is when we can use the Spawn()
function, which you can read more about here.
01 | local h = script.Parent.Humanoid |
02 |
03 | function onDeath() |
04 | if h.Health then |
05 | if h.Health = = 0 then |
06 | game.Lighting.SuperEvilKeycard:Clone().Parent = game.Players.LocalPlayer.Backpack |
07 | script.Parent:Destroy() |
08 | end |
09 | end |
10 | end |
11 |
12 | spawn( function (onDeath)) |
13 |
14 | while true do |
15 | h:MoveTo(workspace.DontClean 1. Position) |
16 | wait( 5 ) |
17 | h:MoveTo(workspace.DontClean 2. Position) |
18 | wait( 5 ) |
19 | end |
If this helped you out, consider accepting this answer. If not, let me know and I'll be sure to help you out further.