Ad
Log in to vote
0

How do I change image gui by leaderstats?

Asked by 7 days ago
Edited 7 days ago

Hello! I am trying to change the image of the gui depending on the leaderstats. It is in serverStorage because that is where the billboard gui is in

EDIT 1: BTW it is a overhead Gui

Here is the code.

local LP = game.Players.LocalPlayer
local Image = script.Parent
local leaderstats = LP:WaitForChild("leaderstats")
local Time = leaderstats:WaitForChild("Time")
game.Players.PlayerAdded:Connect(function()

Time:GetPropertyChangedSignal("Value"):Connect(function()
    while wait() do
    if Time.Value >= 0 then
        Image.Image = "rbxassetid://lmagePaceholder"
    end
    if Time.Value >= 60 then
        Image.Image = "rbxassetid://lmagePaceholder"
    end
    if Time.Value >= 400 then
        Image.Image = "rbxassetid://lmagePaceholder"
    end
    if Time.Value >= 500 then
        Image.Image = "rbxassetid://lmagePaceholder"
    end
        if Time.Value >= 1000 then
        Image.Image = "rbxassetid://lmagePaceholder"
    end
        if Time.Value >= 1200 then
        Image.Image = "rbxassetid://6654794864"
    end
        if Time.Value >= 1600 then
        Image.Image = "rbxassetid://6654795945"
    end
        if Time.Value >= 2000 then
        Image.Image = "rbxassetid://lmagePaceholder"
    end
        if Time.Value >= 3000 then
        Image.Image = "rbxassetid://lmagePaceholder"
    end
        if Time.Value >= 6000 then
        Image.Image = "rbxassetid://ImagePlaceholder"
    end
        if Time.Value >= 1000 then
        Image.Image = "rbxassetid://lmagePaceholder"
    end
        end
    end)
end)
0
When you run the code, what do you see? Is the code working? Robot_R4 0 — 7d
0
I see the first image show up, but not the rest of the images when my time value is changed OhBrotherGaminYT 0 — 7d
0
I noticed that the first 5 images are the same, is that a mistake? Robot_R4 0 — 7d
0
It is suppose to be the same image gui but different immage OhBrotherGaminYT 0 — 7d
View all comments (15 more)
0
Hold on, im looking in to it. Robot_R4 0 — 7d
0
oh, its the same gui name but with different drawing on it? Robot_R4 0 — 7d
0
yes OhBrotherGaminYT 0 — 7d
0
I think you need to rename the images with different names since there different pictures, the program is displaying the gui, which is great, but since there are different images with the same label, it is probably getting confused. Robot_R4 0 — 7d
0
I think all the images should have numbers actually, also, where are you getting the images from? This could help a lot. Robot_R4 0 — 7d
0
How are you doing, was this helpful? Robot_R4 0 — 7d
0
I put the image id instead of ImagePlaceholder so that it could display that image OhBrotherGaminYT 0 — 7d
0
but still doesnt work OhBrotherGaminYT 0 — 7d
0
I am getting the images from my decals OhBrotherGaminYT 0 — 7d
0
Ok, good to know! Let me do some more research.. Robot_R4 0 — 7d
0
Are any pictures popping up when you run it, or nothing. Robot_R4 0 — 7d
0
Only the image that I set it to in properties. OhBrotherGaminYT 0 — 7d
0
Could you resend the code? Robot_R4 0 — 7d
0
Thankyou for being patient with me. Robot_R4 0 — 7d
0
I made a few tweaks OhBrotherGaminYT 0 — 7d

1 answer

Log in to vote
0
Answered by 7 days ago

The new script

local LP = game.Players.LocalPlayer
local rank = script.Parent
Image = {}
Image[1] = "rbxassetid://6654744240"
Image[2] = "rbxassetid://6654785682"
Image[3] = "rbxassetid://6654786566"
Image[4] = "rbxassetid://6654787618"
Image[5] = "rbxassetid://6654788713"
Image[6] = "rbxassetid://6654794864"
Image[7] = "rbxassetid://6654795945"
Image[8] = "rbxassetid://6654796495"
Image[9] = "rbxassetid://6654797149"
Image[10] = "rbxassetid://6654797490"
Image[11] = "rbxassetid://6654797943"



local leaderstats = LP:WaitForChild("leaderstats")
local Time = leaderstats:WaitForChild("Time")
Time.Changed:Connect(function(newvalue)
            if newvalue <= 60 then
                rank.Image = (Image[1])
            else
                if newvalue <= 400 then
                    rank.Image = (Image[2])
                else
                    if newvalue <= 500 then
                        rank.Image = (Image[3])
                    else
                        if newvalue <= 1000 then
                            rank.Image = (Image[4])
                        else
                            if newvalue <= 1200 then
                                rank.Image = (Image[5])
                            else
                                if newvalue <= 1600 then
                                    rank.Image = (Image[6])
                                else
                                    if newvalue <= 2000 then
                                        rank.Image = (Image[7])
                                    else
                                        if newvalue <= 3000 then
                                            rank.Image = (Image[8])
                                        else
                                            if newvalue <= 6000 then
                                                rank.Image = (Image[9])
                                            else
                                                if newvalue <= 10000 then
                                                    rank.Image = (Image[10])
                                                else
                                                    if newvalue <= 99999999999999999 then
                                                        rank.Image = (Image[11])
                                                    end
                                                end
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end                 
end)

0
Did this work? Robot_R4 0 — 7d
0
no OhBrotherGaminYT 0 — 7d
0
ill be back in 20 minutes or more OhBrotherGaminYT 0 — 7d
0
backk OhBrotherGaminYT 0 — 7d
View all comments (5 more)
0
Hello, im still reading your code for errors, thankyou for being patient. Robot_R4 0 — 7d
0
Since, the last program was displaying and this is not displaying instead of rewriting the code, maybe revert to the last code, and just change the "image placehold" to the Id. Or did you already try that? Robot_R4 0 — 6d
0
What last code? OhBrotherGaminYT 0 — 6d
0
Nvm i found out, and all the "image placeholders" are with the actual decal id OhBrotherGaminYT 0 — 6d
0
Yay! So glad you figured it out! Robot_R4 0 — 5d
Ad

Answer this question