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!
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
Because r15 looks ugly and nobody likes it