StringValue not displaying

I’m making a script that cycles through various decals on each click, and saves it into a StringValue (named SValue.) When I click, it doesn’t add to the StringValue; it leaves it blank. Anyone know what I’m doing wrong?

local ImageButton = script.Parent
local NomButtonGui = ImageButton.Parent
local SValue = NomButtonGui.Screen1Value 

value = 1

ImageButton.MouseButton1Up:Connect(function()
		if (value < 5) then
			value = (value + 1)
		else value = 1
	end
	
	if value == 1 then
		SValue.Value = ("http://www.roblox.com/asset/?id=4821413675")
	elseif value == 2 then
		SValue.Value = ("http://www.roblox.com/asset/?id=4821413941")
	elseif value == 3 then
		SValue.Value = ("http://www.roblox.com/asset/?id=4821414237")
	elseif value == 4 then
		SValue.Value = ("http://www.roblox.com/asset/?id=4821414523")
	elseif value == 5 then
		SValue.Value = ("http://www.roblox.com/asset/?id=4821414820")
		
	end
end)

I ran it in my own studio and it seems to be working. A couple of things I suggest are:

  • Make sure its a string value and not another kind like a number value
  • Try doing a different event type

If both of these don’t work bring up the console by clicking view then Output. Try to find the error from there.

1 Like

Really? Oh, strange. Guess I didn’t have anything wrong after all. Thanks anyway!

This morning when I ran it in my studio, the same error occurs. Could I see the way you placed the StringValue in your Workspace to get it to work?

My code is this:

local ImageButton = script.Parent
local NomButtonGui = ImageButton.Parent
local SValue = NomButtonGui.Screen1Value

value = 1

ImageButton.MouseButton1Click:Connect(function()
		if (value < 5) then
			value = (value + 1)
		else value = 1
	end
	
	if value == 1 then
		SValue.Value = "http://www.roblox.com/asset/?id=4821413675"
	elseif value == 2 then
		SValue.Value = "http://www.roblox.com/asset/?id=4821413941"
	elseif value == 3 then
		SValue.Value = "http://www.roblox.com/asset/?id=4821414237"
	elseif value == 4 then
		SValue.Value = "http://www.roblox.com/asset/?id=4821414523"
	elseif value == 5 then
		SValue.Value = "http://www.roblox.com/asset/?id=4821414820"
		
	end
end)

My objects are laid out like this:

img

You need to also make sure when you are checking to see if the string value is changing to check the PlayerGui and not the StarterGui

Gotcha. Thanks so much for helping me!