Image label not updating

idk what is happening but image labels not updating

local function addRankIcon(player, rank)
		

		if rank == "Competente" then
			-- OWNER ICON OVERHEAD
			local guiClone = gui:Clone()
			guiClone.Enabled = true
			guiClone.Parent = player.Character.Head
			guiClone.Adornee = player.Character.Head
			image.Image = "rbxassetid://5436304966"
			
		elseif rank == "Especialista" then
			-- DEV ICON OVERHEAD
			local guiClone = gui:Clone()
			guiClone.Enabled = true
			guiClone.Parent = player.Character.Head
			guiClone.Adornee = player.Character.Head
			image.Image = "rbxassetid://5436304966"
		end
	end
1 Like
if rank == "Competente" then
    -- Set the image for the "Competente" rank
    guiClone.Parent = player.Character.Head
    guiClone.Adornee = player.Character.Head
    local image = guiClone:FindFirstChild("Image")
    image.Image = "rbxassetid://5436304966"
    
elseif rank == "Especialista" then
    -- Set the image for the "Especialista" rank
    guiClone.Parent = player.Character.Head
    guiClone.Adornee = player.Character.Head
    local image = guiClone:FindFirstChild("Image")
    image.Image = "rbxassetid://5436304966"
end

tried it and It still does not work

Can you send the whole code?

And is the rank == “Especialista” an actual rank in a group or just a username.

it’s leaderstats rank:

local gui = game.ReplicatedStorage:FindFirstChild("ImageGui")
local image = gui.ImageLabel

game.Players.PlayerAdded:Connect(function(plr)
	local ls = Instance.new("Folder")
	ls.Name = "leaderstats"
	ls.Parent = plr

	local winsValue = Instance.new("IntValue")
	winsValue.Name = "Wins"
	winsValue.Parent = ls

	local rankValue = Instance.new("StringValue")
	rankValue.Name = "Rank"
	rankValue.Parent = ls

	local function updateRank(wins)
		if wins >= 400 then
			rankValue.Value = "Aether"
		elseif wins >= 300 then
			rankValue.Value = "Divino"
		elseif wins >= 200 then
			rankValue.Value = "Imortal"
		elseif wins >= 150 then
			rankValue.Value = "Supremo Lendário"
		elseif wins >= 100 then
			rankValue.Value = "Supremo"
		elseif wins >= 80 then
			rankValue.Value = "Lendário"
		elseif wins >= 65 then
			rankValue.Value = "Mestre"
		elseif wins >= 50 then
			rankValue.Value = "Destemido"
		elseif wins >= 35 then
			rankValue.Value = "Experiente"
		elseif wins >= 5 then
			rankValue.Value = "Especialista"
		elseif wins >= 1 then
			rankValue.Value = "Competente"
		else
			rankValue.Value = "Iniciante"
		end
	end

	local function addRankIcon(player, rank)


		if rank == "Competente" then
			-- OWNER ICON OVERHEAD
			local guiClone = gui:Clone()
			guiClone.Enabled = true
			guiClone.Parent = player.Character.Head
			guiClone.Adornee = player.Character.Head
			image.Image = "rbxassetid://5436304966"

		elseif rank == "Especialista" then
			-- DEV ICON OVERHEAD
			local guiClone = gui:Clone()
			guiClone.Enabled = true
			guiClone.Parent = player.Character.Head
			guiClone.Adornee = player.Character.Head
			image.Image = "rbxassetid://5436304966"
		end
	end

	local success, data = pcall(function()
		return winsDataStore:GetAsync(plr.UserId .. "-Wins")
	end)

	if success then
		local winsData = data or 0
		winsValue.Value = winsData
		updateRank(winsData)
		addRankIcon(plr, rankValue.Value)
		print("Dados carregados para " .. plr.Name)
	else
		warn("Dados não carregados para " .. plr.Name)

		local failedToLoad = Instance.new("StringValue")
		failedToLoad.Name = "ERRO AO SALVAR DADOS"
		failedToLoad.Value = "Erro ao carregar dados"
		failedToLoad.Parent = plr
	end
end)
local gui = game.ReplicatedStorage:FindFirstChild("ImageGui")
local image = gui.ImageLabel
local winsDataStore = --edit

game.Players.PlayerAdded:Connect(function(plr)
    local ls = Instance.new("Folder")
    ls.Name = "leaderstats"
    ls.Parent = plr

    local winsValue = Instance.new("IntValue")
    winsValue.Name = "Wins"
    winsValue.Parent = ls

    local rankValue = Instance.new("StringValue")
    rankValue.Name = "Rank"
    rankValue.Parent = ls

    local function updateRank(wins)
        if wins >= 400 then
            rankValue.Value = "Aether"
        elseif wins >= 300 then
            rankValue.Value = "Divino"
        elseif wins >= 200 then
            rankValue.Value = "Imortal"
        elseif wins >= 150 then
            rankValue.Value = "Supremo Lendário"
        elseif wins >= 100 then
            rankValue.Value = "Supremo"
        elseif wins >= 80 then
            rankValue.Value = "Lendário"
        elseif wins >= 65 then
            rankValue.Value = "Mestre"
        elseif wins >= 50 then
            rankValue.Value = "Destemido"
        elseif wins >= 35 then
            rankValue.Value = "Experiente"
        elseif wins >= 5 then
            rankValue.Value = "Especialista"
        elseif wins >= 1 then
            rankValue.Value = "Competente"
        else
            rankValue.Value = "Iniciante"
        end
    end

    local function addRankIcon(player, rank)
        if rank == "Competente" then
            -- OWNER ICON OVERHEAD
            local guiClone = gui:Clone()
            guiClone.Enabled = true
            guiClone.Parent = player.Character.Head
            guiClone.Adornee = player.Character.Head
            image.Image = "rbxassetid://5436304966"

        elseif rank == "Especialista" then
            -- DEV ICON OVERHEAD
            local guiClone = gui:Clone()
            guiClone.Enabled = true
            guiClone.Parent = player.Character.Head
            guiClone.Adornee = player.Character.Head
            image.Image = "rbxassetid://5436304966"
        end
    end

    local success, data = pcall(function()
        return winsDataStore:GetAsync(plr.UserId .. "-Wins")
    end)

    if success then
        local winsData = data or 0
        winsValue.Value = winsData
        updateRank(winsData)
        addRankIcon(plr, rankValue.Value)
        print("Dados carregados para " .. plr.Name)
    else
        warn("Dados não carregados para " .. plr.Name)

        local failedToLoad = Instance.new("StringValue")
        failedToLoad.Name = "ERRO AO SALVAR DADOS"
        failedToLoad.Value = "Erro ao carregar dados"
        failedToLoad.Parent = plr
    end
end)

tried again and nope didnt work

What error is given to you when you run the game?

fixed it, this what i did:


local function addRankIcon(wins)
		
		
		if wins >= 5 then
			-- OWNER ICON OVERHEAD
			
			image.Image = "rbxassetid://9326125034"
			
			

			elseif wins >= 1 then
			-- DEV ICON OVERHEAD
		
			image.Image = "rbxassetid://115530144"
		end
		
		local guiClone = gui:Clone()
		guiClone.Enabled = true
		guiClone.Parent = plr.Character.Head
		guiClone.Adornee = plr.Character.Head
		
		
	end


addRankIcon(winsData)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.