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

Why does workspace.CurrentCamera.ViewSizePort stay fixed?

Asked by 7 years ago
Edited 7 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

There is a problem. workspace.CurrentCamera.ViewportSize stays fixed. It doesn't originate to the players screen size at all times. It stays fixed. For example, if I have full screen on, and I make it half screen, it only has the value of the full screen measurements and not the half screen, it stays fixed?!

DeviceFullScreen = workspace.CurrentCamera.ViewportSize HealthBar = script.Parent

XScale = DeviceFullScreen.X YScale = DeviceFullScreen.Y

ActionX = XScale / 2.4 ActionY = YScale / 1.02133333

while true do wait(2) HealthBar.Position = UDim2.new(0, ActionX, 0, ActionY) end

The "DeviceFullScreen" is the measurements of players full screen

The Xscale is the full size of players screen in x coordinates The YScale is the full size of players screen in y coordinates

ActionX is the players XScale divided by 2.4 ActionY is the players YScale divided by 1.02133333

They both equal a number based on the size of the players device Which is what I needed ViewPortSize for. To measure the size of the players screen in both x and y scale.

Then afterwards,

I positioned the HealthBar to the players screeen size divided by those numbers.

So the position of HealthBar in x offset coordinates is the ViewPortSize.X(The measurement of the players full screen), divided by 2.4 Same go's for Y, but instead 1.021... and so on

My purpose was to make the HealthBar be at a certain location of the players screen even after they "Restore Down", or change the size of screen, Like pressing f11, the screen size changes so must the HealthBar position

So to do this, I used "while true do"

So that it will be at a certain part of the players screen at all times even after changing their screen size.

while true do wait(0) HealthBar.Position = UDim2.new(0, XScale, 0, YScale) end

The HealthBar should be at a cetain point based on the Player's Device Screen.

However, when I tested this it worked. There was a problem though. When testing this, I noticed that if I press f11 or change the size of my screen, the HealthBar stays fixed at a certain point and does change position.

I then came to realize that the "ViewPortSize" stayed fixed

The ViewPortSize does not follow the players full screen at all times.

I tested this.

ViewPortSize = workspace.CurrentCamera.ViewportSize while true do wait(2) print(ViewPortSize)

end

Output

632, 807 (x9)

If I change my Roblox game size to half of my screen and press "Play" in roblox studios.

It printed the ViewPortSize and it gave me the axis(632, 807) which is half of my screen.

So, I pressed F11 and changed my Roblox Studio size to full size and it repeatedly printed the same results 9 times (632, 807) (x9)

WHICH MEANS THE VIEWPORTSIZE STAYS THE SAME. IT STAYS FIXED WHICH IS THE REASON WHY IN MY SCRIPT, WHEN I CHANGED THE SIZE OF MY ROBLOX SCREEN, THE HEALTHBAR DIDN'T CHANGE POSITIONS.

DeviceFullScreen = workspace.CurrentCamera.ViewportSize HealthBar = script.Parent

XScale = DeviceFullScreen.X YScale = DeviceFullScreen.Y

ActionX = XScale / 2.4 ActionY = YScale / 1.02133333

while true do wait(2) HealthBar.Position = UDim2.new(0, ActionX, 0, ActionY) end

0
That's odd, are you sure the ViewportSize is actually staying fixed, or did you store it in a variable? If you did something like "size = CurrentCamera.ViewportSize", the value of 'size' won't change when the viewport size does. Pyrondon 2089 — 7y
0
OOOHHHHH dakanji123 97 — 7y
0
Is there a way of accessing the players full size screen at ALL times? dakanji123 97 — 7y

Answer this question