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

(SOLVED) Enemy Not Updating Position, Why?

Asked by 3 years ago
Edited 3 years ago

Solved By This Person.

local UpdatePosition = 0.2 --How long it takes target the next humanoid
local DamageTime = 3 --How long it takes for the enemy to attack again
local Damage = 30 --How much damage the enemy does
--Advanced Config
local AgroDist = 100 --The amount of studs that the enemy can find you at
local HitBox = script.Parent.HitBox --Change to the part that it has to touch to deal damage (example: script.Parent.Head, script.Parent.LeftArm. Make sure it's not the rootpart though)
-- Do not edit the below unless you know what you are doing
local Player = game.Players.LocalPlayer
local enhum = script.Parent.Enemy
local ddb = false
local character
-- This is the real script. Only edit if you know what you are doing
while wait() do
    local player = game.Players.LocalPlayer
    for i, v in pairs(game.Players:GetChildren()) do
     character = game.Workspace:WaitForChild(v.name)
        if (character.Humanoid.RootPart.Position - enhum.RootPart.Position).Magnitude <= AgroDist then
            enhum:MoveTo(character.PrimaryPart.Position)
            enhum.MoveToFinished:Wait(UpdatePosition)
        end
        end

Very confused still though!

0
not sure if it was intended but you are missing an end in the code you posted, the while wait() do loop is still open TGazza 1336 — 3y
0
Not intended! But it was lower down for some reason. But thanks for helping me figure it out a bit, had no idea it was with the ends! allybally12345 40 — 3y

Answer this question