Pathfinding becomes more laggy with an FPS unlocker

I’ve been making an AI to chase the player which has so far been working fine, however there is also another script which utilises a remote event to make the humanoid speed faster.

If I have my FPS capped at 60 the AI speeding up works (although there is still some stutter) however if I uncap my FPS and get from 140-240fps the AI stutters so much it won’t even move. Is there any way to fix this?

Script which speeds up AI:

local Lighting = game:GetService("Lighting")
local TweenService = game:GetService("TweenService")
local sound = game.Workspace.SmilerChase.heartbeat

local tweenInfo = TweenInfo.new(
	2, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out -- EasingDirection
)


local Goal1 = {Contrast = 0.5} 

local Goal2 = {Contrast = 0} 

local firstTween = TweenService:Create(Lighting.ColorCorrection,tweenInfo, Goal1)

local secondTween = TweenService:Create(Lighting.ColorCorrection,tweenInfo, Goal2)

wait(10)

local Smiler = script.Parent
while true do 

local c = math.random(1)
		if c == 1 then
	 
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local remoteEvent = ReplicatedStorage:WaitForChild("RageSpeed")
	remoteEvent:FireAllClients()
		
		Smiler.Humanoid.WalkSpeed = 100000
		
		print(Smiler.Humanoid.WalkSpeed)
	
		firstTween:Play()

		sound:Play()	
		wait(6)
		sound:Play()
		wait(6)
		
		Smiler.Humanoid.WalkSpeed = 22
		secondTween:Play()
		print("Hunt End")
		
		wait(18)
		end 
	end 

The remote event is in Replicated Storage and the Server Script is in ServerScriptService:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RageSpeed")

local Smiler = game.workspace.Smiler
Smiler.PrimaryPart:SetNetworkOwner(nil)

remoteEvent:FireAllClients()

I am relatively new to scripting (just learned how remote events work) so any help is appreciated!

  • Xander