I have found a problem with my script as the zombie does not kill me after it has killed me once. However if I Disable it and enable the script it starts all over again. Is it possible after the script is finished that it can replay it all or if not a way to disable it wait (.1) and enable it again.
Please help!
Sounds like you're looking for a loop. Respectively, the "while" loop. You can use this loop at the beginning of your code, and use the body of it to repeat over and over again. Here's an example:
Here's how it works:
while condition do (Body) end
So, the loop will repeat the code in it's "body" until some false statement is met, or until the loop is broken. Take this example:
while true do print'Looping' end -- BUT WAIT! -- Loops without yielding will cause a very unpleasant crash. To fix this, we can use the wait() -- function. No parameter is needed in this example. while wait() do -- you can also call functions as a condition. print'Looping' end
Sorry if this wasn't what you're looking for, some example code would help.
You can use a script to disable another script
game.Workspace.Zombie.KillScript.Disabled = true -- Disables the script wait(0.1) game.Workspace.Zombie.KillScript.Disabled = false -- Enables it
Loops should help you. Let's say you want it to be an infinite loop, use this;
while true do wait(0.25) -- You always want a wait, or else your game might crash. -- Put your code here and it will go on an infinite loop.
Let's say you only want to be killed by the zombie for a certain amount of time, you'd use this;
for i = 1, 50 do -- replace 50 with how ever many times you want to be killed. Replace 1 to change the starting count... 20-50, 100-1000, ect. --Code goes here, inside of the loop. end
Let's say you've written your follow function above and you don't feel like putting it in one of these loops.
Follow() repeat -- Put code inside here, it will loop until you die. until game.Workspace.Player.Died
I suggest you check out this article about loops.