Help with this npc thing

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m making this npc that plays red light green light from squid game (stole the idea from groovydominoes52) basically it spawns at a random point and moves at green light and stops at red light, it occasionally would have a delay for stopping at red light so it like you know, dies.

  2. What is the issue? Include screenshots / videos if possible!
    this npc stops moving like a few seconds before red light

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I tried checking the values for red light and green light yeah nothing’s wrong with them it’s the npc that just stops moving and I basically gave up lol

here’s like the script I made

local npc = script.Parent.Parent.Parent
local gametype = game.Workspace:WaitForChild("Game") 
local hrp = npc.HumanoidRootPart
local hum = npc.Humanoid
local head = npc.Head
local values = npc.Behaviour.Values
local chance = npc.Behaviour.Values.Chance

-- Function to check and handle game type

gametype.RedGreenLight.Red.Changed:Connect(function()
	if values.Moving.Value == true and values.Finished ~= true then
		script.Shoot:Play()
		hum:TakeDamage(100)
	end
end)

gametype.RedGreenLight.Green.Changed:Connect(function()
	if gametype.RedGreenLight.Green.Value == true and hum.Health ~= 0 then
		local endPoint = gametype.RedGreenLight.EndPoint
		hum:MoveTo(endPoint.Position)
		values.Moving.Value = true
	end
end)

gametype.RedGreenLight.Red.Changed:Connect(function()
	if gametype.RedGreenLight.Red.Value == true and hum.Health ~= 0 then


		values.Moving.Value = false
		hum:MoveTo(hrp.Position)

		task.wait(0.01)
		chance.Value -= math.random(0.01, 8.9)

	end
end)

local function checkGameType()
	if gametype.RedGreenLight.Value == true and hum.Health ~= 0 and values.Finished ~= true then
		local spawns = gametype.RedGreenLight.Spawns:GetChildren()

		local spawnPlace = spawns[math.random(1, #spawns)]
		hrp.CFrame = spawnPlace.CFrame


		
	end
end

task.wait(2)
checkGameType()

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

This is a feature of Humanoid.MoveTo
The reach goal state of a humanoid will timeout after 8 seconds if it doesn’t reach its goal. This is done so that NPCs won’t get stuck waiting for Humanoid.MoveToFinished to fire. If you don’t want this to happen, you should repeatedly call MoveTo so that the timeout will keep resetting.

whahaaa it works tysm :3
thurtie charzz

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.