When the model moves it goes down usually, dont know why.
local modelSCP = script.Parent
local playerName = getClosestPlayer()
local playerCharacter = game.Workspace[playerName]
local distBetweenPlayer = (modelSCP.PrimaryPart.Position - playerCharacter.HumanoidRootPart.Position).Magnitude
if distBetweenPlayer > killDistance then
local part = script.Parent.PrimaryPart
local charPos = playerCharacter.HumanoidRootPart.Position
local lookAtCFrame = CFrame.lookAt(part.Position, charPos)
local modelCFrame = CFrame.fromMatrix(part.Position, lookAtCFrame.XVector, part.CFrame.YVector, lookAtCFrame.ZVector)
if distBetweenPlayer > maxDistTeleport then
modelSCP:SetPrimaryPartCFrame(modelCFrame * CFrame.Angles(0,math.pi,0) * CFrame.new(Vector3.new(1, 1, maxDistTeleport)))
else
modelSCP:SetPrimaryPartCFrame(modelCFrame * CFrame.Angles(0,math.pi,0) * CFrame.new(Vector3.new(1, 1, distBetweenPlayer - killDistance)))
end
else
print("KILL")
end
I think the problem here is that you tell it to go to the Player Primary Part , the player model is smaller than the model of the monster therefor it goes down to get to the destination , i think you should try or setting the destination to the head or make it so it would go a little up from the primary part
ah yeah you’re prolly right, i wasnt paying attention, i thought it should be locked on the axis but i’ve only locked the rotation axis and not the position in the modelCFrame, would making another CFrame with the modelCFrame * CFrame.Angles(0,math.pi,0) property and make the Y position not change? or maybe cast a ray when the model moves, and before and compare the height difference and just set it back to the ground level