Hi, I’m trying to create a script that pretty much moves a part which the camera of the player is attached to move to the middle between two players (or parts)
My current problem is that if you get close to the player then the camera part keeps moving on even though it’s not the middle between both parts anymore.
I really just need the part to be between both players but I’m not sure what math I’d need to use to do so or if I need to do an extra step to fix this.
here’s the example:
This is all in a local script and yes it is working other than the broken part
local plr = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local camerapart = game.Workspace.CameraPart
local char = plr.CharacterAdded:Wait() or plr.Character
local hrp = char:WaitForChild("HumanoidRootPart")
while wait() do
local pos = game.Workspace.Dummy.HumanoidRootPart.Position
local pos2 = hrp.Position
local newpos = pos - pos2 / 2
camerapart.Position = Vector3.new(-3, 4, newpos.Z)
print(newpos)
if newpos.Z <= 20 then
plr.CameraMinZoomDistance = 15
plr.CameraMaxZoomDistance = 15
elseif newpos.Z >= 25 then
plr.CameraMinZoomDistance = 25
plr.CameraMaxZoomDistance = 25
end
end
game.Workspace.activater.Touched:Connect(function(hit)
if hit:FindFirstAncestorOfClass("Model").Name == plr.Name then
start()
end
end)
I just want the camera in the middle