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

How do I make this figure silhouette follow behind the player?

Asked by 4 years ago
Edited 4 years ago

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?

0
put (sloved) raid6n 2196 — 4y

2 answers

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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)
0
I tried game.Players.LocalPlayer but it didnt work alike_yeBro -2 — 4y
0
edited raid6n 2196 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago

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

0
use a code block so if someone has the same problem they can use it raid6n 2196 — 4y

Answer this question