Hello, I made this script, but i really think that is too poorly optimized, and I don’t really know a way to make it more optimized
Not moving:

Moving:
Any help is welcome c:
local character = script.Parent.Parent.Parent
local velocity = character.HumanoidRootPart.AssemblyLinearVelocity.Magnitude;
local RunService = game:GetService("RunService")
local Tween = game:GetService("TweenService")
--local maxvelocity = Vector3.new(0, 0, 16.5)
local maxvelocity = 20
local players = game.Teams.Survivors:GetPlayers()
local player = game.Players:GetPlayerFromCharacter(character)
local gui = player.PlayerGui.Game_Gui.ExposeUI
local anim = require(game.ReplicatedStorage.GuiAnimations)
local Outline_Show = { OutlineTransparency = 0}
local Outline_Invisible = { OutlineTransparency = 1}
RunService.Stepped:Connect(function()
if #players < 3 then
if velocity < maxvelocity then
local highlight = script.Parent.Parent.Parent.Highlight
highlight.Adornee = character
highlight.OutlineColor = Color3.new(1, 1, 1)
--highlight.OutlineTransparency = 0
Tween:Create(highlight, TweenInfo.new(10, Enum.EasingStyle.Back, Enum.EasingDirection.Out, 0, false, 0), Outline_Show):Play()
if character.HumanoidRootPart.AssemblyLinearVelocity.Magnitude > maxvelocity then
local highlight = script.Parent.Parent.Parent.Highlight
Tween:Create(highlight, TweenInfo.new(1, Enum.EasingStyle.Back, Enum.EasingDirection.Out, 0, false, 0), Outline_Invisible):Play()
end
end
end
end)

