Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

PlayerGui not changing image?

Asked by 3 years ago

I have a script in the workspace. It randomly decides between 1 or 2 and changes a string value to either "1" or "2"

while true do

    local math = math.random(1, 2) 

    if math == 1 then

        game.ReplicatedStorage.Value.Value = "1"

    elseif math == 2 then

        game.ReplicatedStorage.Value.Value = "2"

    end
end

I have this script set to change Playergui's image. Script inside an image button.

while true do

    wait (1)

    if game.ReplicatedStorage.Value.Value == "1" then
        script.Parent.Image = 6946020462

    elseif game.ReplicatedStorage.Value.Value == "2" then
        script.Parent.Image = 6946024491

    end
end


The image just appears blank. Thought? And yes, I named my ScreenGui, StarterGUI

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

the ID needs to be in a specific format:

while true do

    wait (1)

    if game.ReplicatedStorage.Value.Value == "1" then
        script.Parent.Image = "rbxassetid://6946020462"

    elseif game.ReplicatedStorage.Value.Value == "2" then
        script.Parent.Image = "rbxassetid://6946024491"

    end
end
Ad

Answer this question