Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script Detects StringValue as a Table. Why and how do i fix it?

I have a AutoShutdownScript on my game that was not made by me and it has an error. A value is detected as a table, not a string value as it is supposed to be.

if placeId == 0 then script:Destroy() end -- No proper info.
local market = game:WaitForChild("MarketplaceService")
local serverVersion = Instance.new("StringValue",game) --This is the StringValue that is detected as a table

serverVersion.Value = market:GetProductInfo(placeId) --This line is where it errors
serverVersion.Name = "SERVER_VERSION"

while true do --Extra code in the script if you want to see it
	game:GetService("RunService").Stepped:wait()
	local currentVersion = market:GetProductInfo(placeId)
	if currentVersion ~= serverVersion.Value then
		if manualShutDown ~= true then
			local m = Instance.new("Message",workspace)
			m.Text = "This game has been updated! Shutting down server..."
			wait(1)
			Instance.new("ManualSurfaceJointInstance",workspace)
		else
			local f,s = string.find(currentVersion,"autoshutdown:go")
			if f ~= nil and s ~= nil then
				local m = Instance.new("Message",workspace)
				m.Text = "This game has been updated! Shutting down server..."
				wait(1)
				Instance.new("ManualSurfaceJointInstance",workspace)
			end
		end
	end
end																															

Please Help

1 answer

✓ Accepted answer

The issue is that you're trying to set a string value to a table value.

serverVersion.Value -- a string = market:GetProductInfo(placeId)  --- get product info returns a table for a place Id 

I'm not proficient with tables enough to show you how to do it, but you could try a for loop that index through that table and then use the value inside that table to assign to your string value

Sorry if that didn't make any sense

This discussion is preserved as it was. New answers, comments, and votes are closed.