it works for me look at the video attached
how does it work for u, wait lemme check if theres italy flag
ahhhhh theres not the italy flag, that my bad, thank you for the help
Just to note for everyone here:
The suggestions youâve had so far have been pretty good, but I would recommend you reconsider using multiple individual images - youâd be better off using spritesheets. You can either create that yourself, or you could look online for a resource, e.g. this CC0 country flag spritesheet here.
This would require very few changes to your current code, but would reduce the amount of HTTP
requests to load each individual image asset - not to mention that these images likely donât have to be very big, so weâre wasting memory by throwing them into individual images.
The biggest change would be that, instead of setting the Image
property, youâd set the ImageRectSize
and ImageRectOffset
of the ImageLabel
- youâll be able to find a few resources about this on the DevForum, Iâm sure.
e.g. in the case of some of the examples here:
Note: This is example code - youâll have to make some changes to make it function
-- in some ImageAssets.lua module
return {
ImageId = 'rbxassetid://the/spritesheet/image/id',
Flags = {
UK = { ImageRectOffset = Vector2.new(0, 0), ImageRectSize = Vector2.new(15, 15) }
-- ... todo: the other rect offsets + sizes from the image you've uploaded
}
}
-- in some ui code
local FlagImageAssets = require(the.image.asset.module)
local LocalizationService = game:GetService('LocalizationService')
local countryCode = LocalizationService:GetCountryRegionForPlayerAsync(player)
local details = countryCode and FlagImageAssets.Flags[countryCode] or nil
if not details then
-- couldn't find the flag, handle this case somehow
return
end
someFlagImageLabel.ImageRectOffset = details.ImageRectOffset
someFlagImageLabel.ImageRectSize = details.ImageRectSize
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.