Hi, when I set the position of a label it will only show up on the top left of the screen when I’m using a random, I was told the 2nd and 4th things parameter were offset so I would only need 0-1, right? Sorry if this is a stupid question
local re = game:GetService("ReplicatedStorage")
local text = re.EatEffect
local remotes = re.Remotes
local effectEvent = remotes.PlayEffect
effectEvent.OnClientEvent:Connect(function(amount)
local effect = text:Clone()
effect.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui
effect.Visible = true
effect.Text = "+"..amount.." Coins"
effect.Position = UDim2.new(0, math.random(0,1), 0, math.random(0,1))
for i = 1, 100 do
wait(0.001)
effect.TextTransparency = i/100
end
end)
When you use Udim.new, the first and third values determine your scale, which ensures it propertionally increases or decreases across different screen sizes
For example if you want your label to be at the centre you can set them at 0.5 and 0.5(which represents 50% of your screen height and width)
For example:
Udim2.new(0.5,-50,0.5,25) centres the label, then shifts it to the left by 50pixels and up by 25pixels
You’d also want to scale the offsets values appropriately so that it looks the same on every device(scale = offset/parentsize(in pixels)
You’ll find plenty of resources to understand this online, and if you want I can send you a youtube video link too
I was wondering how that 1st one was used
effect.Position = UDim2.new(math.random(), 0, math.random(), 0)
Didn’t look right. Trying to consider a mobile also.
What I assume is that he’s like trying to show how much coins a player got on an event
like you pick up a coin and stuff and it shows how much you picked up
like on those simulators
because Nest_co said to because it puts the texts in the center. Earlier I set the offset to -50 - 1000, it worked but when I set it to a mobile device it doesn’t work properly. How do I fix this?
This is what you’ve gotta do, just use the scales instead and leave the offsets empty
Also I recommend setting the AnchorPoint of the label to (0.5,0.5)
So i mentioned earlier that you need to scale it properly, which means taking your offset and dividing it with the parents screen size
So if you want to move it to the left by 100pizels and the player screen size is 800pixels yout scale will be 100/800= 0.125
And your udim will be-
Udim2.new(0.125,0,0,0)