How to solve UIStroke appearing too big on mobile devices

So was i correct? if yes, please delete the topic in order not to waist dev’s time.

1 Like

I was not talking to you, I was referring to @Misterx113. This topic is closed now.

1 Like

Thats the point, its not true, it dosnt work right. Your script in the main post will not work properly.

1 Like

If it does, then show a video or screenshot, because for me it’s not.

1 Like

Sadly I cant event showcase it to you because the script has a error to, you forgot to close the for statement. Not only is the script logic wrong, also the script text. Also is screenGui not definied.

1 Like

After I fixed your script, you see exactly the problem that I saw and explained to you all the time without testing it and you were too ignorant to see it. After having a proper look at the code I have to say: it is simply absolute trash. tbh
Your script:


Orginale:

The script I send in this topic:

Without any script

1 Like

We’re trying to make the UIStroke smaller, not bigger. Your example looks off.

Edit: Look, do what works best for you, but don’t call other people’s way of doing things trash.
This works fine in Roblox Studio for me.

Even if yours is a better alternative, you still have no right to call someone else’s code downright trash. You also never tried tinkering around with the Thickness like I said. That’s on you.

Also this doesn’t even work on other screens. Not every screen resolution is of that of an iPad.

I just did this:

local Player = game.Players.LocalPlayer

local CurrentCamera = game.Workspace.CurrentCamera

local PlayerGui = Player.PlayerGui.MainUI

local Thickness = 2 -- Change this

local ViewportRatio = CurrentCamera.ViewportSize.Y / CurrentCamera.ViewportSize.Y

print(ViewportRatio * Thickness)

local UserInputService = game:GetService("UserInputService")
local TouchEnabled = UserInputService.TouchEnabled


for i, v in pairs(PlayerGui:GetDescendants()) do
	if v:IsA("UIStroke") then
		if TouchEnabled then
			v.Thickness = Thickness * ViewportRatio
		end
	end
end

It appears to work. For all mobile devices.

1 Like

Hey, this is wrong, you have to press play before. The code I send will work when you press play.

That is correct, but in propertion as I have said ~5 times. As I’ve chalked up several times before, it’s no good to just chop everything down to 1, especially not for a community tutourial.

Use different stroke sizes and fix the code you send in this community tutourial, so it dosnt trow an error and then you see that it maxes every ui stroke to this small size, even when ones at 100 and one UIStroke is at 0.01, all go to 1.

I wont test it again. Oh, I can see already that it has the same problem again, but without error ig

. You know that you can acces the thicknes of ever UIStroke?

You shouldn’t have the right to create a misleading community tutorial that beginners follow and see that the code you put together is buggy and doesn’t work as it should.

I can tinker around as much as I want, it would still clump everything together to the value with your FINISHED instruction code - the same problem that I have already pointed out ~7 times.

1 Like

I literally did press play. Like over 10 times, and not once did it work.

That’s crazy.

1 Like

Yea, I am completely with you, why do you do it then?

When you insert this script in a local script in the correct service and enable it, chnage your screensize to whatever and start the game, it will resize all uistrokes to the correct propertionel size.
l

ocal studiosize = Vector2.new(1600,900) -- change this, I just pick random numbers


local function getratio()
    return workspace.CurrentCamera.ViewportSize.Y / studiosize.Y
end

local function onobject(stroke: UIStroke)
    if stroke:IsA("UIStroke") then
        stroke:SetAttribute("Thickness", stroke:GetAttribute("Thickness") or stroke.Thickness)
        stroke.Thickness = stroke:GetAttribute("Thickness") * getratio()
    end
end

local player = game.Players.LocalPlayer
for _, stroke in pairs(player.PlayerGui:GetDescendants()) do
    onobject(stroke)
end
player.PlayerGui.DescendantAdded:Connect(onobject)

Remember to set the screenSize to a correct value.

2 Likes

Your clearly over exaggerating if you’re saying that it’s buggy.

No, it’s underdone, I should actually say faulty, because if I copy it 1to1 from your tutorial, there’s even an error.
Looks like you changed it now. But the biggest problem is still there.
Btw, why only on mobile? On e.g X-Box you have to scale it up [your code would scale all down to the same value], if you would let it be able to run there to [same problem I told you ~8 times about]

2 Likes

It literally just prints out the UIStroke’s thickness. It’s the exact same. You sure you tested this yourself?

1 Like

Read my post again or give me more context.

Don’t recommend this tutorial to anyone if it doesn’t even work.

All I did was:

local Player = game.Players.LocalPlayer

local CurrentCamera = game.Workspace.CurrentCamera

local PlayerGui = Player.PlayerGui.MainUI

local Thickness = 1.5

local ViewportRatio = CurrentCamera.ViewportSize.X / CurrentCamera.ViewportSize.Y

local UserInputService = game:GetService("UserInputService")
local TouchEnabled = UserInputService.TouchEnabled


for i, v in pairs(PlayerGui:GetDescendants()) do
	if v:IsA("UIStroke") then
		if TouchEnabled then
			v.Thickness = v.Thickness / (Thickness * ViewportRatio)
		end
	end
end

Are you gonna bother trying it?

And again, 2 problems
~9 times: Proportion
And again, this script will error you forgot the end

I did, this came out:

I literally put the end there but alright. Are you too lazy to put an end yourself?

Please dont say or express “I DID I DID, YOU LIER”, when you obviously edited it there.
To your edit:
If you send code into community tutorials [obviously untested at the time] with bugs, it’s up to you to remove them. This is lg a tutorial, not a bug tutorial. It shows quite a lot about your learning ability that you even forget to write an ending, even after correcting it in another post.

So what you’re saying is, you can’t properly put an END there when there are LITERALLY red lines that show if a format is incorrect. And you literally didn’t even say

local

properly up there

Shows a lot about your learning ability that you even forget to write an ending, even after correcting it in another post.

you might notice that in my new post with the code that was cut off.

Even bigger shame if you still don’t manage to write your code correctly and send it to a community tutorial. #resources:community-tutorials should be high quality and the OP should know smt about that.