i want to make a mob look at the player but for some reason it glitches around
script one(glitch but it looks at the player) :
while true do
local body = script.Parent
local origin = body.Position
local targetPos = game.ReplicatedStorage.values.torso.Value
local distance = (script.Parent.Position - targetPos).Magnitude
local effect = body.propel
body.CFrame = CFrame.new(origin,targetPos)
if distance > 200 then
targetPos = body:GetAttribute("rand_pos")
body.Parent.Humanoid.MoveToFinished:Connect(function()
effect.Enabled = false
end)
end
body.Parent.Humanoid:MoveTo(targetPos)
if distance > 30 and distance < 200 then
effect.Enabled = true
body.Parent.Humanoid.WalkSpeed = 30
else
if distance < 200 then
effect.Enabled = false
body.Parent.Humanoid.WalkSpeed = 0
end
end
wait()
end
file for script 1:
model.rbxm (18.6 KB)
video:
robloxapp-20220428-1236281.wmv (2.5 MB)
script 2 is just script 1 but with body.CFrame = CFrame.new(origin,targetPos)
removed and although it will not glitch it dosent look at the player
not a flying enemy and it is a server script
model 2 :
model2.rbxm (18.6 KB)
2 Likes
If Iām understanding this correctly I had the same problem with a mob.
Try turning the AutoRotate property in the humanoid to false.
no use bc it was already false
Although they are deprecated, have you tried using BodyGyros? This is a script that I wrote with an example result:
https://i.gyazo.com/5f44adee4f47cfa9a4027a46cee04e75.gif
local hrp = script.Parent.HumanoidRootPart
local gyro = Instance.new("BodyGyro",hrp)
gyro.MaxTorque = Vector3.new(0,40000,0)
function face(position)
gyro.CFrame = CFrame.new(hrp.Position,position)
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local target = character:WaitForChild("HumanoidRootPart")
while task.wait() do
face(target.Position)
end
end)
end)
1 Like
dont worry i always use deprecated items
thanks. new script:
local gyro = Instance.new("BodyGyro",script.Parent)
gyro.P = 1000000
while true do
local body = script.Parent
local origin = body.Position
local targetPos = game.ReplicatedStorage.values.torso.Value
local distance = (script.Parent.Position - targetPos).Magnitude
local effect = body.propel
gyro.MaxTorque = Vector3.new(1000,1000000000,1000)
gyro.CFrame = CFrame.new(body.Position,targetPos)
if distance > 200 then
targetPos = body:GetAttribute("rand_pos")
body.Parent.Humanoid.MoveToFinished:Connect(function()
effect.Enabled = false
end)
end
body.Parent.Humanoid:MoveTo(targetPos)
if distance > 30 and distance < 200 then
effect.Enabled = true
body.Parent.Humanoid.WalkSpeed = 30
else
if distance < 200 then
effect.Enabled = false
body.Parent.Humanoid.WalkSpeed = 0
end
end
wait()
end