Alright so this is a two part question,
First Part:
local torso = script.Parent.UpperTorso.Position
local desk
local username = game.ReplicatedStorage.Events.Username
local human = script.Parent.Humanoid
local animation = script.Parent.Animate.walk.WalkAnim
username.OnServerEvent:Connect(function(player)
wait(math.random(5))
if player.Name == workspace.Green.Owner.Value then
desk = workspace.greendesk.Position
elseif player.Name == workspace.Red.Owner.Value then
desk = workspace.reddesk.Position
end
local path = game:GetService("PathfindingService"):FindPathAsync(torso,desk)
local points = path:GetWaypoints()
if path.status == Enum.PathStatus.Success then
for i,v in pairs(points) do
local track = human:LoadAnimation(animation)
track:Play()
human:MoveTo(v.Position)
if v.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
human.MoveToFinished:wait()
track:Stop()
end
end
end)
so I got an AI, thats scripted to arrive at a desk, 50% of the time it does this; https://gyazo.com/88c0050cd5cd55d96e3b8e6e361a0fc2 but sometimes it does this: https://gyazo.com/22543da4ed98f9d8c445b74b0f649318
Wondering what the situation is with that,
Second part being;
local NPC = game.ReplicatedStorage.NPC
local customer = game.ReplicatedStorage.Events.Customer
local username = game.ReplicatedStorage.Events.Username
local green = workspace.Green.Owner.Value
local red = workspace.Red.Owner.Value
local Owner
customer.OnServerEvent:Connect(function(player)
if player.Name == green then
Owner = workspace.Green.Owner.Value
elseif player.Name == red then
Owner = workspace.Red.Owner.Value
end
print(Owner)
if workspace:FindFirstChild(tostring(Owner).."'s customer") then
print('exisiting')
else
print('new customer')
local newNPC = NPC:Clone()
newNPC.Parent = workspace
newNPC.Name = tostring(Owner).."'s customer"
newNPC.Pathfinding.Disabled = false
print('pathfinding enabled')
end
end)
I'm attempting to make a check eg;
If player.Name's customer exists then; print - existing else create a new NPC and so on
(The player variable from the remote event does work with other scripts)
