Hello guys, today we are making a walking NPC in roblox studio!
There are more than one ways to do this, I am showing one way.
I will be uploading some roblox studio videos this months, if you want me to show something tell me in comments :D
🔴 Script:
local Name = "Rig"
-- Similar name to the NPC
local Loop = true
-- Repeat infinitely
local Regresar = false
-- change it to true if you want the npc to do the path just one time
local IntervaloEnCadaPunto = 0
-- Time wait in each point
local Retraso = 0
-- Time waited at the final point
local RetrasoInicial = 0
-- Time waited since the beginning of the game
local folder = script.Parent
local model = folder.Parent:FindFirstChild(Name) or
folder.Parent:FindFirstChildOfClass("Model"):FindFirstChildOfClass("Humanoid") and folder.Parent:FindFirstChildOfClass("Model")
local humanoid = model:FindFirstChildOfClass("Humanoid")
local function mover(reversa)
if not reversa then reversa = false end
if reversa then
local cantPartes = #folder:GetChildren()
cantPartes -= 1
for i,v in pairs(folder:GetChildren()) do
if v:IsA("Part") then
humanoid:MoveTo(folder:FindFirstChild(cantPartes).Position)
cantPartes -= 1
humanoid.MoveToFinished:Wait()
task.wait(IntervaloEnCadaPunto)
end
end
else
for i,v in pairs(folder:GetChildren()) do
if v:IsA("Part") then
humanoid:MoveTo(v.Position)
humanoid.MoveToFinished:Wait()
task.wait(IntervaloEnCadaPunto)
end
end
end
end
task.wait(RetrasoInicial)
if Loop then
while wait() do
task.wait(IntervaloEnCadaPunto + Retraso)
mover()
task.wait(IntervaloEnCadaPunto + Retraso)
mover(true)
end
else
if Regresar then
mover()
task.wait(IntervaloEnCadaPunto + Retraso)
mover(true)
else
mover()
end
end
🔥 Roblox Community 🔥 https://www.roblox.com/communities/17...
💥 Roblox User 💥 https://www.roblox.com/users/46532207...
📷 Instagram 📷 / red_diego11
🔔 Subscribe 🔔 https://t.co/QdlXav4cGO
📬 Mail 📬 [email protected]
🎵 MUSIC 🎵 N. Sanity Beach soundtrack - Crash Bandicoot
#roblox #robloxstudio #npc #script #scripting #walk #walking