I don't know why. My Follow script wont work on Roblox, It does in studio but not in real Roblox can you help? The Zombie I made should follow the closest player, but it in studio is works but on Roblox they just stand still
local humanoid = script.Parent.Zombie local Torso = script.Parent.Torso local MaxDistance = 999999999999 function MoveTowardsAPerson(pos) local People = {} local MoveTo for i,v in pairs(workspace:GetChildren()) do if v:IsA("Model") and v:findFirstChild("Humanoid") then if game.Players:GetPlayerFromCharacter(v) then table.insert(People,v) end end end for i,v in pairs(People) do local pos2 = v.Torso.Position local mag = (pos - pos2).magnitude if mag <= MaxDistance and game.Players:FindFirstChild(v.Name).CanFollow.Value == true then MoveTo = v.Torso end end if MoveTo ~= nil then return MoveTo end end while game:GetService("RunService").RenderStepped:wait() do if humanoid.Health > 1 then local t = MoveTowardsAPerson(Torso.Position) if t ~= nil then humanoid:MoveTo(t.Position) end end end
You are using RenderStepped in a script.
Because the client-server relation is different in studio, renderstepped will fire in a script, but on a real server it will only fire in LocalScripts.
More info:http://wiki.roblox.com/index.php?title=API:Class/RunService/RenderStepped