Josiahiscool73

mobile screen fixer

Nov 23rd, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. -- mobile screen fixer
  2.  
  3.  
  4.  
  5. local VirtualRes = Vector2.new(1280, 720)
  6. local Cam = workspace.CurrentCamera
  7. local Core = game:GetService("CoreGui")
  8. local LP = game:GetService("Players").LocalPlayer
  9. local PGui = LP:WaitForChild("PlayerGui")
  10.  
  11. local function FixRes(gui)
  12. if not gui:IsA("ScreenGui") then return end
  13. if gui.Name == "RobloxGui" or gui.Name == "TouchGui" then return end
  14.  
  15. local scale = math.min(Cam.ViewportSize.X / VirtualRes.X, Cam.ViewportSize.Y / VirtualRes.Y)
  16.  
  17. local uiscale = gui:FindFirstChildOfClass("UIScale") or Instance.new("UIScale", gui)
  18. uiscale.Scale = scale
  19. end
  20.  
  21. local function Watch(parent)
  22. for _, v in ipairs(parent:GetChildren()) do
  23. pcall(FixRes, v)
  24. end
  25. parent.ChildAdded:Connect(function(v)
  26. task.wait()
  27. pcall(FixRes, v)
  28. end)
  29. end
  30.  
  31. Watch(Core)
  32. Watch(PGui)
  33.  
  34. Cam:GetPropertyChangedSignal("ViewportSize"):Connect(function()
  35. Watch(Core)
  36. Watch(PGui)
  37. end)
Advertisement
Add Comment
Please, Sign In to add comment