Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- players = nil; --Where we are going to store all the players
- dummy = game.Workspace.Dummy; --Dummy reference
- currentPlayerFollowing = nil; --The current player the zombie is following
- while wait(1) do --Forever loop
- players = game.Players:GetChildren(); --Grab all the Players currently in the game
- for i = 0, table.getn(players), 1 do --Go through all of the players
- if (players[i] ~= nil and (math.abs(players[i].Character.Torso.Position.X - dummy.Torso.Position.X)) <= 10) then --Subtract the distance between the player and the zombie
- currentPlayerFollowing = players[i]; --Add the player to the currentPlayerFollowing reference so the zombie can follow them
- end
- end
- if (currentPlayerFollowing ~= nil) then --If the player is there
- dummy.Humanoid.WalkToPoint = currentPlayerFollowing.Character.Torso.Position --Walk to the player
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement