Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do i make Doors rush like monster?

Asked by 1 year ago

Hello, I wanted to make Rush like entity to run trought the whole map but the problem is that each waypoint the monster stops walking for 8 seconds after hitting a waypoint and continues walking

Here is what I did

local npc = script.Parent
local humanoid = npc:FindFirstChild("Humanoid")
local waypoints = workspace:FindFirstChild("WaypointsFolder")
local waypointnumber = 1
local waypointscount = 38

for count = 1, waypointscount do
    humanoid:MoveTo(waypoints:FindFirstChild("Waypoint"..waypointnumber).Position)
    humanoid.MoveToFinished:Wait()
    waypointnumber += 1
end

Is there any way to just tween the monster anchored with the same speed to each waypoint?

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

There is, infact! By using relatively simple code, you can make it go from one point to the other!

local waypoints = workspace:FindFirstChild('WaypointsFolder')
local Rush = script.Parent
local TweenService = game:GetService('TweenService')
local currWaypoint = 0
local speed = 1 -- you can edit this however you like

wait(2)

for _, i in pairs(waypoints:GetChildren()) do
    currWaypoint += 1
    if waypoints:FindFirstChild(currWaypoint) then
        local Goal = {Position = waypoints:FindFirstChild(currWaypoint).Position}
        local Waypoint = TweenService:Create(Rush, TweenInfo.new(speed,Enum.EasingStyle.Linear), Goal)
        Waypoint:Play()
    else
        print("ended loop!")
        break
    end
    wait(speed)
end
wait(2)
Rush:Destroy()

Let me know if anything goes wrong!

Ad

Answer this question