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

Smallening a frame (screenGUI) with distance??

Asked by 3 years ago

I have made an script where an frame moves to a certain part's position within workspace on the screen:

local camera = workspace.CurrentCamera
local worldPoint = Vector3.new(0, 10, 0)
local frame = script.Parent:WaitForChild("Frame")
local part = workspace:WaitForChild("Part")
local partp = part.Position
local partpx = part.Position.X
local partpy = part.Position.Y
local partpz = part.Position.Z


while wait(0.11) do
    local vector, onScreen = camera:WorldToScreenPoint(Vector3.new(partpx, partpy, partpz))
    frame.Position = UDim2.fromOffset(vector.X, vector.Y)
end

But I also want the frame to change size the closer you get it enlarges and the further you get away it smallens.

I've thought of making local formulas that will make distance be part of a multiplier. But I don't think it's a really good idea. Can anyone help me with this?

Answer this question