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

Why am I getting this error with R15 people, but not R6 people?

Asked by 7 years ago
Edited 7 years ago

I have tried to make a zombie script that can even chase R15 people. but for some reason ROBLOX can't detect a character. This works with R6, but not with R15.

Here's the script:

players = nil; 
dummy = script.Parent
currentPlayerFollowing = nil; 

while wait(0.1) do 
 players = game.Players:GetChildren(); 
 for _, player in pairs(players) do
    local character = game.Workspace:FindFirstChild(player.Name)
  if (player ~= nil and (math.abs(character.PrimaryPart.Position.X - dummy.Torso.Position.X)) <= 20) then 
   currentPlayerFollowing = player; 
  end
 end

 if (currentPlayerFollowing ~= nil) then 
    dummy.Humanoid.WalkToPoint = currentPlayerFollowing.Character.Torso.Position 
end
end

And here's the error I keep getting for R15 people:

21:25:55.173 - Workspace.Minion. .FollowScript:9: attempt to index local 'character' (a nil value) 21:25:55.174 - Stack Begin 21:25:55.175 - Script 'Workspace.Minion. .FollowScript', Line 9 21:25:55.176 - Stack End

It would be highly apprieciated if someone could help me out with this. Thanks!

EDIT: All I needed to do was add another wait since the character does not spawn instantly, it's solved!

0
Suggest using player.Character instead. RubenKan 3615 — 7y
0
I have already tried that. NeonicPlasma 181 — 7y

2 answers

Log in to vote
0
Answered by
Nogalo 148
7 years ago

The issue is that R15 characters don't have the part "Torso". Instead they have Upper and Lower Torso with the Upper Torso being the Primary part of the model, so you'll have to work around that

0
This is not what he's asking about. AstrealDev 728 — 7y
0
it is outlook1234567890 115 — 7y
Ad
Log in to vote
-3
Answered by 7 years ago

Because r15 looks ugly and nobody likes it

0
Is that relevant to scripting at all? NeonicPlasma 181 — 7y
0
Is that relevant to scripting at all? NeonicPlasma 181 — 7y

Answer this question