Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

In roblox how would I Make a bot/NPC runaway when it gets to close to a player/ other humanoid?

Asked by 8 years ago
Edited 8 years ago

How would you make a bot/npc run away from a player if the player gets to close, and when you kill the bot how would you make it drop something, like a brick.

In conclusion how would you reverse a humanoid following you? I wrote this script but it doesnt seem to work on the bot/NPC

local phase = script.Parent.Phase
local h = script.Parent.Humanoid

while true do
    game.Workspace:WaitForChild("Player")
    local plr = game.Workspace:FindFirstChild("Player")
    if phase.Value == "Run" then
        script.Parent.Torso.Velocity = plr.Torso.CFrame.lookVector * 16
--      h:Move(Vector3.new(math.random(-1,1), 0, math.random(-1,1)), true)
    end
    wait()
end

Where would I put the script after the revisions that have been made? (if there were any)

Thanks =)

0
Could you please format your code? iDarkGames 483 — 8y
0
I did can you help me ? yieldinglegoguy1234 0 — 8y

Answer this question