I am trying to make it so depending on your rank in the group, the startergui image changes locally.
My problem is that the image id is not being changed and just remains as the placeholder. I have tried deleting unnecessary variables and adding concatenations, but I’m not sure what else could be a potential issue.
All of the images used are stored in asset manager (if it means anything), my script is inside of its label inside of startergui.
Here is my code:
local rank = game.Players.LocalPlayer:GetRankInGroup(4939664)
local image = script.Parent.Image
if rank == 1 then
image = "rbxassetid://12340415890"
elseif rank == 2 then
image = "rbxassetid://12340415890"
elseif rank == 3 then
image = "rbxassetid://12340416075"
elseif rank == 4 then
image = "rbxassetid://12340416205"
elseif rank == 5 then
image = "rbxassetid://12340416332"
elseif rank == 6 then
image = "rbxassetid://12340416462"
elseif rank == 7 then
image = "rbxassetid://12340416628"
elseif rank == 8 then
image = "rbxassetid://12340416826"
elseif rank == 9 then
image = "rbxassetid://12340417013"
elseif rank == 10 then
image = "rbxassetid://12340417265"
elseif rank == 11 then
image = "rbxassetid://12340417520"
elseif rank == 12 then
image = "rbxassetid://12340417770"
elseif rank == 13 then
image = "rbxassetid://12340417999"
elseif rank == 14 then
image = "rbxassetid://12340418183"
elseif rank == 15 then
image = "rbxassetid://12340418491"
elseif rank == 16 then
image = "rbxassetid://12340418633"
elseif rank == 17 then
image = "rbxassetid://12340418804"
elseif rank == 18 then
image = "rbxassetid://12340418970"
elseif rank == 19 then
image = "rbxassetid://12340419145"
elseif rank >= 20 then
image = "rbxassetid://12340419410"
else
image = "rbxassetid://12340415890"
end
Why the hell are you using loads of elseif 's? It would be way better and readable if you where to just create a dictionary with all of the ranks inside and then just searching for the rank inside of the dictionary.
Could you explain what your issue is? You have said it is logic error but this could mean anything?
I didn’t know what else to use other than elseif. My issue is that my image Id is not being changed and just remains as the initial placeholder, sorry I wasn’t very clear in the message.
After doing some testing I think I know the issue. If rather then doing .Image right away in the variable, you should set the image inside of the if statement (or however you change it up to make the code better).
Why would you even do a loop? Could you not just do an if statement checking if the rank is inside of the dictionary via an if statement and if it is then change it. Although the loop would work it would just be more simple to do it via like 1-2 lines of code.
But I just also wanted to point out that in local image = script.Parent.Image you didn’t have to put .image at the end because that would have caused the script to fail.