Run it
Copy the script and paste it into your executor.
Players = :()
RunService = :()
Workspace = :()
UserInputService = :()
player = Players.LocalPlayer
character = player.Character player.CharacterAdded:()
humanoid = character:()
rootPart = character:()
moveDirection = .(.() * - , , .() * - ).Unit
isStanding =
standStart =
standDuration =
walkDuration =
walkUntil =
checkCooldown =
centerPosition =
wanderRadius =
lastPositions = {}
stuckDetected =
stuckCounter =
maxStuckTime =
obstacleMemory = {}
lastObstacleTime =
obstacleMemoryDuration =
emotionalState =
emotionalStateTimer = .(, ) /
emotionalStateDuration = .(, ) /
curiosityLevel =
socialAwareness =
personalityTraits = {}
frameCount =
lastFrameUpdate =
utilityScores = {}
nearbyPlayers = {}
playerDetectionRange =
personalSpace =
imitationChance =
curiosityTarget =
curiosityTimer =
boredomLevel =
npcEnabled =
personalityTraits = {
patience = + .() * ,
sociability = + .() * ,
curiosity = + .() * ,
caution = + .() * ,
energy = + .() * ,
consistency = + .() * ,
playfulness = + .() * ,
anxiety = + .() * ,
focus = + .() * ,
adaptability = + .() *
}
ScreenGui = .()
ScreenGui.Name =
ScreenGui.ResetOnSpawn =
ScreenGui.IgnoreGuiInset =
(()
player.PlayerGui:()
player.PlayerGui:():()
)
ScreenGui.Parent = player.PlayerGui
(parent, zIndex)
left = .()
left.Size = .(, , , )
left.BackgroundColor3 = .(, , )
left.BorderSizePixel =
left.ZIndex = zIndex
left.Active =
left.Parent = parent
top = .()
top.Size = .(, , , )
top.BackgroundColor3 = .(, , )
top.BorderSizePixel =
top.ZIndex = zIndex
top.Active =
top.Parent = parent
right = .()
right.Size = .(, , , )
right.Position = .(, -, , )
right.BackgroundColor3 = .(, , )
right.BorderSizePixel =
right.ZIndex = zIndex
right.Active =
right.Parent = parent
bottom = .()
bottom.Size = .(, , , )
bottom.Position = .(, , , -)
bottom.BackgroundColor3 = .(, , )
bottom.BorderSizePixel =
bottom.ZIndex = zIndex
bottom.Active =
bottom.Parent = parent
mainFrame = .()
mainFrame.Size = .(, , , )
mainFrame.Position = .(, -, , )
mainFrame.BackgroundColor3 = .(, , )
mainFrame.BorderSizePixel =
mainFrame.ZIndex =
mainFrame.ClipsDescendants =
mainFrame.Parent = ScreenGui
(mainFrame, )
titleBar = .()
titleBar.Size = .(, -, , )
titleBar.Position = .(, , , )
titleBar.BackgroundColor3 = .(, , )
titleBar.BorderSizePixel =
titleBar.ZIndex =
titleBar.Parent = mainFrame
titleLabel = .()
titleLabel.Size = .(, -, , )
titleLabel.Position = .(, , , )
titleLabel.BackgroundTransparency =
titleLabel.Text =
titleLabel.TextColor3 = .(, , )
titleLabel.Font = .Font.Code
titleLabel.TextSize =
titleLabel.TextXAlignment = .TextXAlignment.Left
titleLabel.ZIndex =
titleLabel.Parent = titleBar
collapseButton = .()
collapseButton.Size = .(, , , )
collapseButton.Position = .(, -, , )
collapseButton.BackgroundColor3 = .(, , )
collapseButton.BorderSizePixel =
collapseButton.Text =
collapseButton.TextColor3 = .(, , )
collapseButton.Font = .Font.Code
collapseButton.TextSize =
collapseButton.ZIndex =
collapseButton.Parent = titleBar
(collapseButton, )
titleDivider = .()
titleDivider.Size = .(, -, , )
titleDivider.Position = .(, , , )
titleDivider.BackgroundColor3 = .(, , )
titleDivider.BorderSizePixel =
titleDivider.ZIndex =
titleDivider.Parent = mainFrame
contentFrame = .()
contentFrame.Size = .(, -, , -)
contentFrame.Position = .(, , , )
contentFrame.BackgroundTransparency =
contentFrame.ZIndex =
contentFrame.Parent = mainFrame
isDragging =
dragStart =
frameStartPos =
(input)
isDragging =
dragStart = input.Position
frameStartPos = mainFrame.Position
()
isDragging =
titleBar.InputBegan:((input)
input.UserInputType == .UserInputType.Touch input.UserInputType == .UserInputType.MouseButton1
(input)
)
titleBar.InputEnded:((input)
input.UserInputType == .UserInputType.Touch input.UserInputType == .UserInputType.MouseButton1
()
)
titleLabel.InputBegan:((input)
input.UserInputType == .UserInputType.Touch input.UserInputType == .UserInputType.MouseButton1
(input)
)
titleLabel.InputEnded:((input)
input.UserInputType == .UserInputType.Touch input.UserInputType == .UserInputType.MouseButton1
()
)
UserInputService.InputChanged:((input)
isDragging (input.UserInputType == .UserInputType.Touch input.UserInputType == .UserInputType.MouseMovement)
delta = input.Position - dragStart
mainFrame.Position = .(
frameStartPos.X.Scale,
frameStartPos.X.Offset + delta.X,
frameStartPos.Y.Scale,
frameStartPos.Y.Offset + delta.Y
)
)
UserInputService.InputEnded:((input)
input.UserInputType == .UserInputType.Touch input.UserInputType == .UserInputType.MouseButton1
()
)
collapseButton.MouseButton1Click:(()
mainFrame.Size.Y.Offset >
mainFrame:(.(, , , ), , , , )
collapseButton.Text =
contentFrame.Visible =
mainFrame:(.(, , , ), , , , )
collapseButton.Text =
contentFrame.Visible =
)
(toggleText, yPosition, default, callback)
button = .()
button.Size = .(, , , )
button.Position = .(, -, , yPosition)
button.BackgroundColor3 = default .(, , ) .(, , )
button.Text = toggleText .. .. (default )
button.TextColor3 = .(, , )
button.Font = .Font.Code
button.TextSize =
button.BorderSizePixel =
button.ZIndex =
button.Active =
button.Selectable =
button.Parent = contentFrame
(button, )
state = default
debounce =
()
debounce
debounce =
state = state
button.Text = toggleText .. .. (state )
button.BackgroundColor3 = state .(, , ) .(, , )
(state)
.(, ()
debounce =
)
button.Activated:(toggle)
button
(, , , (state)
npcEnabled = state
npcEnabled humanoid
humanoid:(rootPart.Position)
)
()
character character.Parent
humanoid humanoid.Parent
rootPart rootPart.Parent
humanoid.Health <=
()
parts = {}
children = Workspace:()
_, child (children)
child:() child.CanCollide child.Transparency < child.Size.Magnitude >
.(parts, child)
child:()
_, descendant (child:())
descendant:() descendant.CanCollide descendant.Transparency < descendant.Size.Magnitude >
.(parts, descendant)
#parts ==
rootPart.Position,
minX, maxX = .huge, -.huge
minZ, maxZ = .huge, -.huge
_, part (parts)
pos = part.Position
size = part.Size
minX = .(minX, pos.X - size.X / )
maxX = .(maxX, pos.X + size.X / )
minZ = .(minZ, pos.Z - size.Z / )
maxZ = .(maxZ, pos.Z + size.Z / )
center = .((minX + maxX) / , rootPart.Position.Y, (minZ + maxZ) / )
radius = .((maxX - minX) / , (maxZ - minZ) / ) *
center, .(radius, )
()
angle = .() * .pi *
.(.(angle), , .(angle))
(direction, distance)
()
rayParams = RaycastParams.()
rayParams.FilterType = .RaycastFilterType.Blacklist
rayParams.FilterDescendantsInstances = {character}
rayOrigin = rootPart.Position + .(, , )
rayResult = Workspace:(rayOrigin, direction * distance, rayParams)
rayResult
hit = rayResult.Instance
hit hit.CanCollide hit.Transparency < hit.Size.Magnitude >
hit hit.Parent
hitPlayer = Players:(hit.Parent)
hitPlayer
(direction, distance)
()
checkPosition = rootPart.Position + direction * distance + .(, , )
rayParams = RaycastParams.()
rayParams.FilterType = .RaycastFilterType.Blacklist
rayParams.FilterDescendantsInstances = {character}
rayOrigin = checkPosition + .(, , )
rayResult = Workspace:(rayOrigin, .(, -, ), rayParams)
rayResult
hitPart = rayResult.Instance
hitPart ( hitPart.CanCollide hitPart.Transparency >= )
heightDiff = .(rootPart.Position.Y - rayResult.Position.Y)
heightDiff >
()
() -moveDirection
rayParams = RaycastParams.()
rayParams.FilterType = .RaycastFilterType.Blacklist
rayParams.FilterDescendantsInstances = {character}
bestDir =
bestDist =
i = ,
angle = .() * .pi *
dir = .(.(angle), , .(angle))
rayOrigin = rootPart.Position + .(, , )
rayResult = Workspace:(rayOrigin, dir * , rayParams)
dist = rayResult (rayResult.Position - rayOrigin).Magnitude
dist > bestDist (dir, )
bestDist = dist
bestDir = dir
bestDir bestDir
perpDir = moveDirection:(.(, , ))
.() < perpDir = -perpDir
newDir = (-moveDirection + perpDir).Unit
(newDir, ) (newDir, )
newDir = -moveDirection
newDir
()
centerPosition
centerPosition, wanderRadius = ()
() ()
toCenter = centerPosition - rootPart.Position
toCenter = .(toCenter.X, , toCenter.Z)
distToCenter = toCenter.Magnitude
distToCenter > wanderRadius
toCenter.Unit
baseAngle = .(toCenter.Z, toCenter.X)
angleVariation = .() * .pi / - .pi /
directionChoice = .()
newAngle
directionChoice <
newAngle = baseAngle + .pi / + angleVariation
directionChoice <
newAngle = baseAngle - .pi / + angleVariation
newAngle = baseAngle + angleVariation
newDir = .(.(newAngle), , .(newAngle))
(newDir, )
newDir = ()
newDir
()
()
.(lastPositions, rootPart.Position)
#lastPositions > .(lastPositions, )
#lastPositions >=
totalMovement =
i = , #lastPositions
totalMovement = totalMovement + (lastPositions[i] - lastPositions[i-]).Magnitude
totalMovement <
stuckCounter = stuckCounter +
stuckCounter >= maxStuckTime
stuckDetected =
stuckCounter =
stuckCounter = .(, stuckCounter - )
stuckDetected =
()
nearbyPlayers = {}
()
_, plr (Players:())
plr ~= player
char = plr.Character
char
hrp = char:()
hrp
dist = (rootPart.Position - hrp.Position).Magnitude
dist < playerDetectionRange
.(nearbyPlayers, {player = plr, distance = dist, position = hrp.Position})
()
utilityScores = {}
()
utilityScores.idleStand =
utilityScores.avoidEdge = ((moveDirection, ) isStanding)
utilityScores.avoidObstacle = ((moveDirection, ) isStanding)
utilityScores.escapeStuck = stuckDetected
utilityScores.returnToCenter = (centerPosition (centerPosition - rootPart.Position).Magnitude > wanderRadius)
utilityScores.wanderRandomly = ( isStanding stuckDetected)
utilityScores.idleStand = isStanding
utilityScores.explore = (emotionalState == emotionalState == emotionalState == )
utilityScores.socialInteraction = (socialAwareness > #nearbyPlayers > )
utilityScores.imitate = (.() < imitationChance #nearbyPlayers > )
utilityScores.curious = (curiosityLevel > )
highestUtility =
bestBehavior =
behavior, utility (utilityScores)
utility > highestUtility
highestUtility = utility
bestBehavior = behavior
bestBehavior
(behavior)
()
behavior ==
moveDirection = ()
isStanding =
standStart = ()
standDuration =
behavior ==
moveDirection = ()
.() < personalityTraits.caution
isStanding =
standStart = ()
standDuration =
behavior ==
moveDirection = ()
isStanding =
walkDuration = .(, ) /
walkUntil = () + walkDuration
stuckDetected =
lastPositions = {}
behavior ==
toCenter = (centerPosition - rootPart.Position).Unit
moveDirection = toCenter
isStanding =
walkDuration = .(, ) /
walkUntil = () + walkDuration
behavior ==
isStanding
targetPos = rootPart.Position + moveDirection *
humanoid:(targetPos)
behavior ==
humanoid:(rootPart.Position)
behavior ==
isStanding
targetPos = rootPart.Position + moveDirection *
humanoid:(targetPos)
behavior ==
#nearbyPlayers >
target = nearbyPlayers[]
dirToPlayer = (target.position - rootPart.Position).Unit
target.distance < personalSpace
moveDirection = ()
moveDirection = dirToPlayer
behavior ==
#nearbyPlayers > .() <
target = nearbyPlayers[.(, #nearbyPlayers)]
targetChar = target.player.Character
targetChar
targetHRP = targetChar:()
targetHRP
targetVelocity = targetHRP.Velocity
targetVelocity.Magnitude >
moveDirection = targetVelocity.Unit
behavior ==
curiosityTarget
randomAngle = .() * .pi *
randomDist = .(, )
curiosityTarget = rootPart.Position + .(.(randomAngle), , .(randomAngle)) * randomDist
curiosityTimer = .(, ) /
curiosityTarget
moveDirection = (curiosityTarget - rootPart.Position).Unit
curiosityTimer = curiosityTimer -
curiosityTimer <=
curiosityTarget =
()
()
player.Character player.Character ~= character
character = player.Character
humanoid = character:()
rootPart = character:()
centerPosition, wanderRadius = ()
moveDirection = ()
isStanding =
walkDuration = .(, ) /
walkUntil = () + walkDuration
checkCooldown =
lastPositions = {}
stuckDetected =
stuckCounter =
obstacleMemory = {}
npcEnabled
now = ()
now - lastFrameUpdate <
lastFrameUpdate = now
()
()
bestBehavior = ()
(bestBehavior)
checkCooldown > now
isStanding
humanoid:(rootPart.Position)
now - standStart >= standDuration
isStanding =
moveDirection = ()
walkDuration = .(, ) /
walkUntil = now + walkDuration
(moveDirection, )
moveDirection = ()
isStanding =
standStart = now
standDuration =
checkCooldown = now +
(moveDirection, )
moveDirection = ()
isStanding =
standStart = now
standDuration =
checkCooldown = now +
humanoid:(rootPart.Position + moveDirection * )
now >= walkUntil
isStanding =
standStart = now
standDuration = .(, ) /
centerPosition, wanderRadius = ()
moveDirection = ()
walkDuration = .(, ) /
walkUntil = () + walkDuration
RunService.Heartbeat:(onHeartbeat)
player.CharacterAdded:((newCharacter)
character = newCharacter
humanoid = character:()
rootPart = character:()
centerPosition, wanderRadius = ()
moveDirection = ()
isStanding =
walkDuration = .(, ) /
walkUntil = () + walkDuration
checkCooldown =
lastPositions = {}
stuckDetected =
stuckCounter =
obstacleMemory = {}
)NPC script

Universal