I am okay at script but I am not really good. I need to move this figure silhouette behind the player where it follows the player. But I do not know how and I cannot find anything on YouTube...
Here is the script I have for now but is not working:
player = game.Players:GetPlayerFromCharacter() torso = player:FindFirstChild("Torso") while true do script.Parent.Torso.Position.X = torso.Position.X script.Parent.Torso.Position.Y = torso.Position.Y script.Parent.Torso.Position.Z = torso.Position.Z wait(.1) end
Any suggestions of how I can fix it?
while true do would just crash the server
local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player) torso = player:FindFirstChild("Torso") while wait(.1) do script.Parent.Torso.Position.X = torso.Position.X script.Parent.Torso.Position.Y = torso.Position.Y script.Parent.Torso.Position.Z = torso.Position.Z wait(.1) end end)
I found out how. It was: local larm = script.Parent:FindFirstChild("HumanoidRootPart") local rarm = script.Parent:FindFirstChild("HumanoidRootPart")
function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 10000 local temp = nil local human = nil local temp2 = nil for x = 1, #list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then temp = temp2:findFirstChild("HumanoidRootPart") human = temp2:findFirstChild("Humanoid") if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end end end return torso end
while true do wait(math.random(1,5)) local target = findNearestTorso(script.Parent.HumanoidRootPart.Position) if target ~= nil then script.Parent.Humanoid:MoveTo(target.Position, target) end
end