boyparis
(B0re4li5)
September 7, 2021, 11:24pm
#1
This is the script i am using
local Vector = Object.Adornee.Parent.Parent.CurrentCamera:WorldToScreenPoint(Rig.PrimaryPart.Position)
print(Vector)
Effect.Position = UDim2.fromScale(Vector.X , Vector.Y)
Effect.Parent = SelfCreature.Adornee:FindFirstAncestorWhichIsA("ScreenGui")
The Rig’s PrimaryPart is the red cube.
XY obtained from WorldToScreenPoint represent pixels offset from the top left of the screen and not scale.
Use Udim2.fromOffset instead.
1 Like
To add to what @dthecoolest said it’ll work fine on one resolution but if the player minimizes the window then it won’t scale properly
To fix that you can just normalize:
(You’re gonna need a reference for the GUI itself for the resolution)
local GUI = -- path
local normalized = Vector / GUI.AbsoluteSize
Effect.Position = UDim2.fromScale(normalized.X , normalized.Y)
Excuse me for any mistakes I am on phone!
EDIT: you can also just detect whenever absolute size changes and update the variables
2 Likes
boyparis
(B0re4li5)
September 8, 2021, 3:34pm
#4
Weird cause when i print it out it always returns less than 1, and offset rounds down.
boyparis
(B0re4li5)
September 8, 2021, 3:35pm
#5
I will try this solution as soon as i can
boyparis
(B0re4li5)
September 8, 2021, 4:33pm
#6
This places the part at 0,0,0,0
The Camera is in a ViewportFrame btw in case that changes things
If i print out vector the value given is less than 1 which leads me to believe that it returns scale and not offset, at least when in a viewportframe.