Pretty simple thing to do but very good tutorial for beginners
TLDR: Use UserInputService
to check if Touch.Enabled = true
and if so set the UIStroke
thickness to something different by using either an IntValue
or simply a number value.
Pretty simple thing to do but very good tutorial for beginners
TLDR: Use UserInputService
to check if Touch.Enabled = true
and if so set the UIStroke
thickness to something different by using either an IntValue
or simply a number value.
some issues for the code, here is a corrected version
if TouchEnabled then
UIStroke.Thickness = StrokeThickness
end
for index, value in pairs(ScreenGui:GetDescendants()) do
if value:IsA("UIStroke") then
value.Thickness = StrokeThickness
end
end
You only stated the property, you didn’t assign anything to it.
touchê, guess that backfired
Sorry about some typos. I fixed them now. Thank you for reminding me though. I will look for more typos if I find any.
Sorry that I say it that harsh, but there’s a much better script from @bluebxrrybot
local 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)
I you script at least 3 important things are missing:
Screen Size of studio to calculate with
UI Stokes do not always have the same thickney
And do not calculate to 1 always, (different display sizes, the normal value changes etc…)
I would say this tutorial is pointless, the important calculations are missing!
It works either way, so what is the point?
Edit: I printed the UIStroke’s thickness before and after, so it does work. I’ll use this in my future games.
print(UIStroke.Thickness) -- Prints 3
stroke.Thickness = stroke:GetAttribute("Thickness") * getratio()
print(UIStroke.Thickness) -- Prints 1.1472222805023193
This tutorial needs a pictures of the UIStroke appearing too big on mobile devices because the UIStroke works fine on mobile devices.
What do you mean?
PC:
Mobile:
oh, in this image its not the UIStroke that is big
It’s the image of the bar that is small
Not sure
It’s a possibility though
I think that you made a script that makes the bars smaller on mobile and forgot to do the same for the UIStroke.
Thank you for the suggestion. I used this in Studio and it worked for all mobile devices.
So was i correct? if yes, please delete the topic in order not to waist dev’s time.
Thats the point, its not true, it dosnt work right. Your script in the main post will not work properly.
If it does, then show a video or screenshot, because for me it’s not.
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.
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:
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.
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.