About 2 days ago, I was working on making the enemy move, and I wanted to try it out myself.
Then when the enemy was moving, it started bugging out and not properly moving. I found out that it had to do with some type of script interfering with the movement (Which some type of script was).
I wanted to figure out why this script for positioning the characters is interfering with the movement script?
I have two types of scripts, and I dont know where the issue could possibly be for the enemy to be laggy and move.
These are what are messing up the enemy’s movement script.
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humrp = char:WaitForChild('HumanoidRootPart')
game:GetService('RunService').RenderStepped:Connect(function()
for _, MODEL in pairs(workspace:GetChildren()) do
if MODEL:IsA('Model') and MODEL:FindFirstChild('DummyBot') then
MODEL:WaitForChild('HumanoidRootPart').CFrame = CFrame.lookAt(MODEL:WaitForChild('HumanoidRootPart').Position, Vector3.new(humrp.CFrame.X, MODEL:WaitForChild('HumanoidRootPart').CFrame.Y, MODEL:WaitForChild('HumanoidRootPart').CFrame.Z))
task.wait()
end
end
end)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humrp = char:WaitForChild('HumanoidRootPart')
game:GetService('RunService').RenderStepped:Connect(function()
for _, MODEL in pairs(workspace:GetChildren()) do
if MODEL:IsA('Model') and MODEL:FindFirstChild('DummyBot') then
humrp.CFrame = CFrame.lookAt(humrp.Position, Vector3.new(MODEL:WaitForChild('HumanoidRootPart').CFrame.X, humrp.CFrame.Y, humrp.CFrame.Z))
task.wait()
end
end
end)
I tried to make up some solutions, but it would just make the player more buggy. (Such as changing the position of the HRP’s.)
Ideas on how I can improve this so the enemy moves smoothly will be needed. Thank you.
My fault for not explaining, the scripts that i added in the post are for making the CFrame the same as the other characters HRP so they dont try and turn around and look crazy.
(The scripts are for the characters to face eachother.)
I can provide a video for you to show what I am talking about. robloxapp-20220801-1239399.wmv (497.5 KB)
Yes, and for the enemy to constantly look at the player too.
I apologize if the video is buggy!
The scripts went inside of startergui.
They also check for an enemy and make sure its in the workspace, then check if it has a BoolValue called “DummyBot” so they know its an actual bot the player can look at.
The issue is that the enemy is not moving smoothly, and i think it is due to the scripts that i provided in the post. I wanted to see if anyone can improve it so the enemy can move smoothly and not buggy.
Could you show me a video of you and the dummy facing eachother please? To record, just go to the view tab and search for “Video Record” then click it to record when inside the game.
Yeah. The movement for the enemy would usually stop and not fully move to the position of where i want it to go. the enemy would also bug out a lot and go into the floor.
I was thinking it was because of the orientation scripts that were provided in the post, and it turned out to be that.
Now I am trying to figure out how to improve the orientation scripts so the enemy can move smoothly.
This is the script for the movement, and it works perfectly fine.
Alright, so im coming back after 2 days of thinking and want to know how to use AlignOrientation. I would appreciate a simple explanation from anyone who knows what it is!