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

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

Asked by
2_MMZ 1059 Moderation Voter
3 years ago
Edited 3 years ago

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!

0
Do you have a HumanoidRootPart or Torso inside of the Model? xInfinityBear 1777 — 3y
0
Yes. I have a HumanoidRootPart, Humanoid, and a Torso. 2_MMZ 1059 — 3y
0
because of the million times you helped me, ill try to help you with this. Xyternal 247 — 3y

1 answer

Log in to vote
0
Answered by
2_MMZ 1059 Moderation Voter
3 years ago

I have figured out how to do this.

Ad

Answer this question