Image Not Updating

I’m trying to make a map voting system, but when I try to update the image labels to correspond with the Gui, it just turns blank. I’m kinda washed at scripting so I can’t fix this.

Here’s my script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MapVotingFolder = ReplicatedStorage:WaitForChild("MapVoting")
local StartVotingRE = MapVotingFolder:WaitForChild("StartVoting")
local UpdateImagesRE = MapVotingFolder:WaitForChild("UpdateImages")
local CastVoteRE = MapVotingFolder:WaitForChild("CastVote")
local Map1Option = MapVotingFolder:WaitForChild("Map1Option")
local Map2Option = MapVotingFolder:WaitForChild("Map2Option")
local Map3Option = MapVotingFolder:WaitForChild("Map3Option")
local Map1OptionCount = Map1Option:WaitForChild("Count")
local Map2OptionCount = Map2Option:WaitForChild("Count")
local Map3OptionCount = Map3Option:WaitForChild("Count")
local Map1ImageID = Map1Option:WaitForChild("Image")
local Map2ImageID = Map2Option:WaitForChild("Image")
local Map3ImageID = Map3Option:WaitForChild("Image")
local Timer = MapVotingFolder:WaitForChild("Timer")

local player = game.Players.LocalPlayer
local playerVote = player:WaitForChild("Voted")

local VoteGui = script.Parent
local MapButton1 = VoteGui:WaitForChild("MapButton1")
local MapButton2 = VoteGui:WaitForChild("MapButton2")
local MapButton3 = VoteGui:WaitForChild("MapButton3")

local Map1Image = MapButton1:WaitForChild("ImageLabel")
local Map2Image = MapButton2:WaitForChild("ImageLabel")
local Map3Image = MapButton3:WaitForChild("ImageLabel")

local TimerLabel = VoteGui:WaitForChild("TimerLabel")

StartVotingRE.OnClientEvent:Connect(function(value)
	VoteGui.Enabled = value
end)

local function castVote(newVote)
	CastVoteRE:FireServer(newVote)
end

MapButton1.MouseButton1Click:Connect(function()
	castVote(Map1Option.Value)
end)

MapButton2.MouseButton1Click:Connect(function()
	castVote(Map2Option.Value)
end)

MapButton3.MouseButton1Click:Connect(function()
	castVote(Map3Option.Value)
end)

while true do
	if VoteGui.Enabled and 
		Map1Option.Value ~= "" and 
		Map2Option.Value ~= "" and 
		Map3Option.Value ~= "" 
	then
		TimerLabel.Text = Timer.Value
		MapButton1.Text = Map1Option.Value .. " (" .. Map1OptionCount.Value .. ")"
		MapButton2.Text = Map2Option.Value .. " (" .. Map2OptionCount.Value .. ")"
		MapButton3.Text = Map3Option.Value .. " (" .. Map3OptionCount.Value .. ")"

		Map1Image.Image = "rbxassetid://" .. Map1ImageID.Value
		Map2Image.Image = "rbxassetid://" .. Map2ImageID.Value
		Map3Image.Image = "rbxassetid://" .. Map3ImageID.Value
	end
	task.wait(0.1)
end
1 Like

make sure its an image not a decal, if it is an image then try to print "rbxassetid://" .. Map1ImageID.Value and see if it actually prints the right value

it could be a decal.
If you want to get image during runtime “dynamically” you can use InsertService
Althrough clean up instances it creates after becouse it will not get gced most likely.

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