Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

NPC won't move to the position I want it to?

Hey! I'm making a horror-story game that includes various beings trying to get you. In the beginning of the game, you are required to get a key that allows you to enter the building. When you walk inside, a cutscene will begin. I'm using a RemoteEvent, and a BindableEvent. Everything else in the script works just fine though.

Regular Script (That fires the RemoteEvent)


local remEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent3")

local debounce = false

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:getPlayerFromCharacter(hit.Parent)
	if player then
		if not debounce then
			debounce=true
			script.Parent.CanCollide = true
			remEvent:fireClient(player)
		end
	end
end)

Regular Script (That fires the BindableEvent)


local remEvent = game.ReplicatedStorage:WaitForChild("BindableEvent3")

local debounce = false

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:getPlayerFromCharacter(hit.Parent)
	if player then
		if not debounce then
			debounce=true
			script.Parent.CanCollide = true
			remEvent:Fire()
		end
	end
end)

LocalScript (That receives the fire from the RemoteEvent)

local remEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent3")
local camera = game.Workspace.Camera
remEvent.OnClientEvent:Connect(function()
	script.Parent.Visible = true
	local player = script.Parent.Parent.Parent.Parent
	local char = player.Character
	char.HumanoidRootPart.CFrame = game.Workspace.SpawnLocation.CFrame
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = game.Workspace.insidetheplacecamera.CFrame
	script.Parent.Parent.Dialogue.Visible = true
	script.Parent.Parent.Dialogue.Frame.Visible = true
	script.Parent.Parent.Dialogue.Frame.speaker.Text = "Thomas"
	script.Parent.Parent.Dialogue.Frame.TextLabel.Text = "We're finally in."
	wait(3)
	script.Parent.Parent.Dialogue.Frame.TextLabel.Text = "Yeah, let's look around."
	script.Parent.Parent.Dialogue.Frame.speaker.Text = "Elijah"
end)

Regular Script (That receives the fire from the BindableEvent)

local remEvent = game.ReplicatedStorage:WaitForChild("BindableEvent3")
local npc = game.Workspace.elieli
local checkpoint1 = game.Workspace.movetoplace1

remEvent.Event:Connect(function()
	wait(2)
	npc.Humanoid:MoveTo(checkpoint1.Position)
end)

The scripts locations are:

Regular Script that fires bindable event: Workspace Part Regular Script that fires remote event: Workspace Part

LocalScript that receives fire from Remote Event: StarterGUI Regular Script that receives fire from Bindable Event: ServerScriptService

Any working answer is appreciated!

3 comments

0

Do you have a HumanoidRootPart or Torso inside of the Model?

0

Yes. I have a HumanoidRootPart, Humanoid, and a Torso.

0

because of the million times you helped me, ill try to help you with this.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.