Remote not working?

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

  1. What do you want to achieve? Penguin working tycoon!

  2. What is the issue? The remote is not received on client (it doesn’t even print), but it does make the penguin pathfind on both server and client and this reproduces 10-50% of the time

  3. What solutions have you tried so far? Tried pushing the remote outside the pathfinding sucess

:PLAYING FUCTION ON CLIENT
game.ReplicatedStorage.Remotes.NCP.PlayAnimNPC.OnClientEvent:Connect(function(uid,name)
	print("BOB")
	if workerArray[uid] == nil then return end
	local worker  =workerArray[uid]
	local track = worker[1].AnimationController.Animator:LoadAnimation(worker[1].Animation[name])
	track:Play()
	playingAnim = track
end)
:FIRING SERVER
local function moveWork(plr,uid,pos,cfg,obj)
	--print(WorkerArray)
	--print(WorkstationsArray)
	
	local path = game.PathfindingService:CreatePath(agentParameters)
	local success, errorMessage = pcall(function()
		path:ComputeAsync(WorkerArray[plr.UserId][uid][2], pos)
	end)
	remotes.NCP.PlayAnimNPC:FireClient(plr,uid,"Walk")
	if not success then 
		print(errorMessage)
	elseif success and path.Status == Enum.PathStatus.Success then
		local waypoints = path:GetWaypoints()
		for i,v in ipairs(waypoints) do
			local nextpos
			if not waypoints[i+1] then
				nextpos =  obj.End.Position
			else
				nextpos =  waypoints[i+1].Position
			end
			local t = (WorkerArray[plr.UserId][uid][2] - (v.Position+Vector3.new(0,cfg.Parameters.Offset.Value,0))).Magnitude/cfg.Parameters.Speed.Value
			remotes.NCP.MoveNPC:FireClient(plr,uid,v.Position+Vector3.new(0,cfg.Parameters.Offset.Value,0),t,nextpos)
			--task.delay(t,function()
				--remotes.NCP.MoveNPC:FireAllClients(uid,pos,0)
			--end)
			
			local p = Instance.new("Part")
			p.Anchored = true
			p.CanCollide = false
			p.CanQuery = false
			p.Size = Vector3.new(0.2,0.2,0.2)
			p.Position = v.Position
			p.Parent = workspace
			task.wait(t)
			WorkerArray[plr.UserId][uid][2] = v.Position
		end
		remotes.NCP.StopAnimNPC:FireClient(plr,uid)
		remotes.NCP.WorkNPC:FireClient(plr,uid,obj)
	end
end

Could you show me where the server’s moveWork() function is being called?

1 Like
game.ServerScriptService.Events.NCP.NPCSpawn.Event:Connect(function(name,pos,plr)
	--print("SPAWNING")
	local cfg =  game.ServerStorage.Penguins:FindFirstChild(name)
	if not cfg then return end
	--print("CFG")
	if WorkstationsArray[plr.UserId] == nil then return end
	if WorkerArray[plr.UserId] == nil then
		WorkerArray[plr.UserId] = {}
	end
	--print("WORKAREA")
	local SpawnPos = pos
	
	table.insert(WorkerArray[plr.UserId],{name,Vector3.new(SpawnPos.X,SpawnPos.Y,SpawnPos.Z)})
	remotes.NCP.SpawnNPC:FireClient(plr,name,#WorkerArray[plr.UserId],Vector3.new(pos.X,pos.Y + cfg.Parameters.Offset.Value,pos.Z))
	
	local found = false
	local object = nil
	local GoalPos = nil
	for key,v in pairs(WorkstationsArray[plr.UserId]) do
		if found then break end
		if v[2] == false then
			for _,operation in pairs(cfg.Parameters.OperateableMachinery:GetChildren()) do
				if operation.Value.Name == v[1] then
					found = true
					GoalPos = Vector3.new(tonumber(string.split(key,",")[1]),0.5+cfg.Parameters.Offset.Value,tonumber(string.split(key,",")[3]))
					v[2] = true
					object = v[3]
					break
				end
			end
		end
		
	end
	if found then
		task.wait(1)
		moveWork(plr,#WorkerArray[plr.UserId],GoalPos,cfg,object)
		
	end
end)

The problem is likely here. Are these statements being printed properly after the return statements?

But the point is, It does run because the next function actually cause the penguin to path find, But it does not play the walking animation 10-50% of the time.

and also it seems that if the first one dont work, the next one wont