You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Penguin working tycoon!
-
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
-
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