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

Is there a way of accessing player's screen size?

Asked by 7 years ago
Edited 7 years ago

I understand that you can access the value of the size of a player's screen through ScreenGui, however is there another way of accessing a player's FULL screen size in all the values/coordinates.

For example, is there a method of accessing the value of a players FULL screen without using ScreenGui, and also containing the coordinates and axis such as X and Y scale of the player's screen

Also, I don't understand much of the UserInputService

If I wanted to make a script where for every time R was pressed, print("R was pressed") would be printed.

I tried

game:GetService("UserInputService").InputBegan:connect(function() if Enum.Keycode.R then print("R was pressed") end

-- But it doesn't work.

Could you, by chance, give me some tutorials of UserInputService which contains in inputs such as keyboard and mouse inputs. Also, could you give me some tutorials for ContentActionService

These, are the ONLY factors I am having trouble understanding in Roblox wiki.

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

To answer your first question:

workspace.CurrentCamera.ViewportSize

This is a Vector2 value.


As for your second question:

Your code is only slightly wrong: the UserInputService's events pass an 'InputObject' value as an argument that contains the relevant data. You're also missing an end:

game:GetService("UserInputService").InputBegan:connect(function(inpt)
    if inpt.KeyCode == Enum.KeyCode.R then
        print("R was pressed")
    end
end)
0
Bookmarking this. OldPalHappy 1477 — 7y
0
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?! dakanji123 97 — 7y
0
That definitely isn't true? You're probably saving the Vector2 value to a variable - at that point if the ViewportSize updates, your variable will stay the same. adark 5487 — 7y
0
How do you access the viewportsize at all times? dakanji123 97 — 7y
Ad

Answer this question