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

Script not working to make the NPC move to a specific part?

Asked by
uhjos_h 19
4 years ago

Basically, I have tried to make an NPC that moves to a specific part, basically it works, but it doesn't move the NPC at the right time, basically 3 seconds in.

1local timeend = false
2local npc = script.Parent
3wait (14)
4timeend = true
5if timeend == true then
6    npc.Humanoid:MoveTo(workspace.yesyes.Position)
7end

I have looked on things like Youtube, the DevForum, and here for a solution and still cannot manage to get it to work.

2 answers

Log in to vote
0
Answered by 4 years ago

Hey! Sorry I answered a bit late but I have a thought that might be somewhat useful.

So basically, every set amount of time, a object (or npc in your case will move to a set location every time it gets told too, it also moves furthest away from the player(s) and doesn't move to the same space 2 times in a row.

SETUP: Figure it out I'm too lazy sorry i'm doing a skribbl.io tournament lol

Here:

01local npcModel = game.Workspace.Crate1
02local npcLocationFolder = game.Workspace.GameFolder.DepositFolder
03local SET_TIME = 14
04 
05local npcLocations = crateLocationFolder:GetChildren()
06 
07-- Moves the NPC to locationPart's position
08local function moveNPCToPart(locationPart)
09    npcModel:SetPrimaryPartCFrame(locationPart.CFrame)
10end
11 
12local function getTotalPlayerDistanceFromPart(locationPart)
13    local totalDistance = 0
14 
15    local players = game.Players:GetPlayers()
View all 47 lines...

if it breaks just message me and i will see whats wrong cya :D

Ad
Log in to vote
0
Answered by
uhjos_h 19
4 years ago

Never mind, it works! Feel free to use this code in your game, I just counted the wait time wrong.

Answer this question