Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

2 comments

0

Suggest using player.Character instead.

0

I have already tried that.

2 answers

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

2 comments

0

This is not what he's asking about.

0

it is

Because r15 looks ugly and nobody likes it

2 comments

0

Is that relevant to scripting at all?

0

Is that relevant to scripting at all?

This discussion is preserved as it was. New answers, comments, and votes are closed.