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

How can I stop a humanoid from getting too close to a player?

Asked by 8 years ago
Edited 8 years ago

I have been working on a new project and wanted to incorporate pets or followers, However when I made them follow the players the pet kept walking into the player pushing the player. Is there a way I can make it so that they only follow the player if there is a big enough gap between the two? here is the script that I have been using

01local larm = script.Parent:FindFirstChild("Left Arm")
02local rarm = script.Parent:FindFirstChild("Right Arm")
03 
04function findNearestTorso(pos)
05    local list = game.Workspace:children()
06    local torso = nil
07    local dist = 30
08    local temp = nil
09    local human = nil
10    local temp2 = nil
11    for x = 1, #list do
12        temp2 = list[x]
13        if (temp2.className == "Model") and (temp2 ~= script.Parent) then
14            temp = temp2:findFirstChild("Torso")
15            human = temp2:findFirstChild("Humanoid")
View all 33 lines...
0
Idk really how but I was thinking maybe you can have parts around the "pet" so the pet could not get too close.. FiredDusk 1466 — 8y
0
But then the parts around the pet would push you PikminLegion 38 — 8y
0
Just make the pet move to a certain distance away from the player than a body part of the player alphawolvess 1784 — 8y

Answer this question