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

Why Isn't My NPC Movement Script Working Properly Online? (It works fine in studio!)

Here is the code I've put in a script in workspace, that runs the game essentially.

local ShowDialog = game.ReplicatedStorage.ShowDialog
local ShowTinaDialog = game.ReplicatedStorage.ShowTinaDialog
local Opening = game.ReplicatedStorage.Opening
local OpeningWalk = game.ReplicatedStorage.OpeningWalk
	
--//Waiting for Players
	while true do
		wait(2)
		contestants = {}
		for _, player in pairs(game.Players:GetPlayers()) do
			if player and player.Character then
				local humanoid = player.Character:WaitForChild("Humanoid")
				if humanoid and humanoid.Health > 0 then
					table.insert (contestants, player)
				end
			end
		end
		if #contestants >= 1 then
			print "We have enough"
			break
		else
			end
	end

--//Table of Team Names (referred to as tribes bc i forgot i was making tdi and not survivor)
local Tribes = { 'Dancing Mice', 'Shouting Wolves', 'Thriller Whales', 'Running Lions', 'Sitting Ducks' }	

--//Setting up Teams
print "Choosing teams."
local team = Instance.new("Team")
team.TeamColor = BrickColor.random()
team.Parent = game:GetService("Teams")
local teamnumberchosen = math.random(5)
team.Name = Tribes[teamnumberchosen]
team.AutoAssignable = false
table.remove(Tribes, (teamnumberchosen))
print "Team one made."

local team = Instance.new("Team")
team.TeamColor = BrickColor.random()
team.Parent = game:GetService("Teams")
local teamnumberchosen = math.random(4)
team.Name = Tribes[teamnumberchosen]
team.AutoAssignable = false
table.remove(Tribes, (teamnumberchosen))
print "Team two made."

--//Opening Sequence
OpeningWalk:FireAllClients()
print "Walking fired."
Opening:FireAllClients()
print "Opening fired."

And here is the code inside of StarterGUI which makes the NPC move.


Opening = game:GetService("ReplicatedStorage").OpeningWalk
--//More Variable Thingies
local model = workspace.TinaOpening
local hum = model.Tina.Humanoid

hum.WalkSpeed = 10

--//Make her WALK
local function onOpeningWalk()
	print "Starting to walk"
		hum:MoveTo(model.PointA.Position)
		hum.MoveToFinished:Wait()
		hum:MoveTo(model.PointB.Position)
		hum.MoveToFinished:Wait()
		hum:MoveTo(model.PointC.Position)
		hum.MoveToFinished:Wait()
		hum:MoveTo(model.PointD.Position)
		hum.MoveToFinished:Wait()
		hum:MoveTo(model.PointE.Position)
		hum.MoveToFinished:Wait()
		print "Done walking."
end

Opening.OnClientEvent:connect(onOpeningWalk)
	

The thing is, it DOES work, it just doesn't do it instantly. How can I fix this? I apologize for the errors I've made but I'm still rather new to scripting.

2 comments

0

To add on, it does print out what I've made it print, but the character doesn't actually walk. I've tried using Vector3, I've tried using serverevent, and I've tried it in a localscript.

0

Oh, it appears the script has been messed up a bit on the site. I assure there isn't as many comments on the actual script.

1 answer

Bump, I've made an advancement and got it to at least MOVE online, but there's still errors! I really hope someone can help.

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