If/elseif not working?

I know this is NOT efficient but here you go anyway

	if plr:IsInGroup(roka) then
		if plr:GetRankInGroup(roka) == 5 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 6 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 7 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 8 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 9 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 10 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 11 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 12 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 13 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 14 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 16 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 17 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) == 19 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		elseif plr:GetRankInGroup(roka) >= 20 then
			plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
		else
			plr.Character.Humanoid.Health = 0
		end

the weird thing is that some ranks work here(like 6, 7, 20) but some ranks(like 9 and other) doesn’t work and I got no idea why…

Any console error codes, we’ll work forwards from that.

Looking forwards to your response!

Try adding another end. I think you are missing an end

if plr:IsInGroup(roka) then
    if plr:GetRankInGroup(roka) == 5 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 6 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 7 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 8 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 9 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 10 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 11 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 12 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 13 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 14 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 16 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 17 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) == 19 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    elseif plr:GetRankInGroup(roka) >= 20 then
        plr.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id="
    else
        plr.Character.Humanoid.Health = 0
    end
end

You forgot to close the if statement. Also, to make your code more cleaner, please use tables to store the rank and clothes data then you could just use 1 if statement.

no I actually extracted a part of the script so its closed nicely… and as I said, some ranks do work

lemme ask my friend(rank9 to do it rn)

I can tell you are missing an end

Try using tables instead to remove the plethora of blocks.

local templates = {
  [5] = "http://www.roblox.com/asset/?id=etc."
  [6] = "http://www.roblox.com/asset/?id=etc."
}

-- the rank as an index should correspond with the desired assetid

if plr:IsInGroup(roka) then
   local rank = plr:GetRankInGroup(roka)
   plr.Character.Shirt.ShirtTemplate = templates[rank]
end
1 Like

Look at this - You need to add another end

1 Like

Vouch, this would be a more clean way to configure your shirts and to pick up on errors quicker.

1 Like

Alright it seemed like a error or something… it works nicely now sorry for making it a big deal

and the script was indeed closed with an end… I happened to took a part of the script and didnt bring end with me

Glad you fixed it, be sure to always check console for errors to diagnose your issues.

1 Like