i am trying to make a part welded to a tool, look twards/point twards the direction of the closest player character, i have been trying for hours, i have tried literaly everything, can someone please explain how to make this work
while task.wait(1) do
if equipped then
local closest = nil
local cloesestdistance = nil
for _, player in pairs(game.Players:GetPlayers()) do
local character = player.Character
if plr and plr.Character and plr.Character:FindFirstChild("Torso") and character and plr.Name ~= player.Name then
local distance = player:DistanceFromCharacter(plr.Character.Torso.Position)
if not cloesestdistance or cloesestdistance > distance then
closest = player
cloesestdistance = distance
end
end
end
if closest and closest.Character and closest.Character:FindFirstChild("Torso") and plr and plr.Character and plr.Character:FindFirstChild("Torso") then
local pivot = script.Parent.Handle.pointer:GetPivot()
local lookAtCFrame = CFrame.lookAt(pivot.Position, closest.Character.Torso.Position)
local rotatedCFrame = lookAtCFrame * CFrame.Angles(0, math.pi, 0)
--script.Parent.Handle.pointer.CFrame = CFrame.lookAt(script.Parent.Handle.pointer.Position, closest.Character.Torso.Position)
print(rotatedCFrame)
script.Parent.Handle.Weld.C1 = script.Parent.Handle.Weld.Part1.CFrame:ToObjectSpace(lookAtCFrame)
--script.Parent.Handle.Weld.C1 = rotatedCFrame
end
end
end
all im tryna do is make the part face twards a diff part, no matter the look direction or wtv of the player idk how that would corrolate to anything but yee
yeee, basicly i have a tool, its the roblox geo locator gear, i added a part unanchored and cantcollide, welded to the gears handle, im trying to make the part face twards the closest player
i cant take videos sry, but basicly the part even tho the same 2 values get inputed, the tools position and the closest players position, it rotates completly randomly for no reason even tho the same 2 numbers get inputed idek im done with roblox rn
ig its aparently impossible to get a welded part to point twards the closest player, thats kinda crazy 21 years in the making and you cant do smthn so simple
and theres multiple things there because ive tried everything 100 times 100 diff ways each and got lazy taking stuff out and adding it back or changing it so ye its kinda messy but im just lf someone that knows how to make a welded part face closest player since aparently its forbiden knowledge